In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you the principle of Discuz theme pageviews and the method of not updating, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
The main contents of this paper are as follows:
Solve the problem that the number of page views of the Discuz topic does not change or change with the number of posts this time.
If you are a novice discuz developer, you can view the article from scratch.
If you are a webmaster, just read the summary at the bottom of the article.
Problem reduction
This page is the theme page.
The pageviews with the theme of the red box above use $_ G [forum _ thread] [views]
The number of replies below is $_ G [forum _ thread] [replies]
However, the number of page views will not increase when we refresh the page, but it will increase when we reply to a post on a topic.
Then we are in the test, add a reply, we will find that this is indeed the case! But the problem is not that simple, please continue to see the following
Troubleshooting steps
Step 1: we need to make sure that the number of views and posts are these two fields.
Step 2: we need to trace the principle of the increase in pageviews.
So let's troubleshoot the first problem: open the database dictionary to look at the pre_forum_thread table, then we make sure that the variables we use in the source code are correct
Trace the principle of the realization of pageviews
In line 986 of the code, we solved our first problem, that is, why the number of page views is the same as the number of posts, which is because a judgment is made here. If the number of reply posts is greater than the number of page views of the topic, it will make the number of page views equal to the number of reply posts.
Then continue to look for the code to update the pageviews of the theme: there is the viewthread_updateviews method in line 1054, and we can all literally understand what this method is for, the pageviews of the theme update.
The steps performed by this code
First go back to determine whether the optimization topic pageviews optimization function is enabled in the background.
Then judge the value of addviews in the global variable.
If this value is less than 100, the data will be updated to the pre_forum_threadaddviews table.
If the value of addviews is greater than 100, the pageviews of this topic will be cleared, and then the data will be saved in the views field of the pre_forum_thread theme table.
This is the basic implementation process.
In the above, we found that pageviews are not directly stored in the theme table, which has the advantage of preventing frequent updates and locking of the theme table.
Summary
At this point, I think I understand that the reason why the number of page views on the topic does not increase is actually controlled by the background, because in the first line of the previous code, you can see that this refresh value controls whether or not to optimize the number of page views of the topic.
Just configure it according to Kaka.
But as a developer, the implementation of a function point must be traced back to the source code, only in this way can you continue to improve yourself.
The above is all the content of the Discuz topic pageview realization principle and non-updated method, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.