Discuz theme views implementation principle and solution to non-updating
Main content of this article:
Solution to the problem that the Discuz topic views do not change or change together with the number of reply posts
If you are a novice discuz developer, you can view the article from the beginning
If you are a webmaster, just read the summary at the bottom of the article
More articles are in the column: Discuz column
Questions Restore
This page is the theme page
The red box above is the theme pageviews using $_G[forum_thread][views]
All the replies below use $_G[forum_thread][replies]
for the number of replies. However, the number of views will not increase when we refresh the page, but when the topic replies to a post, the number of views will not increase. The volume will increase
# Then let’s test it and add a new reply, and we will find that it is indeed the case! But the problem is not that simple, please continue to read below
Troubleshooting steps
Step one: We need to confirm the number of views and replies Is the volume of these two fields
The second step: We need to trace the principle of the increase in pageviews
Then let’s troubleshoot the first step Question: Open the database dictionary to view the pre_forum_thread table, then we will confirm that the variables we use in the source code are correct
Traceability implementation The principle
In line 986 of the code, we have solved our first problem, which is why the data of page views and replies are the same. This is because here Made a judgment. If the number of reply posts is greater than the number of topic views, the number of views will be equal to the number of replies
Then continue to look for the code to update the topic views: at 1054# There is a viewthread_updateviews method in the ## line. According to the literal meaning, we can all understand what this method does, and the theme updates the number of views.
The steps to execute this code
- First check whether the optimization theme views optimization function is turned on in the background
- Then determine the value of
addviews in the global variable
- If the value is less than 100, the data will be updated to
pre_forum_threadaddviews This table
- If the value of
addviews is greater than 100, the views of this topic will be cleared, and then the data will be stored in pre_forum_thread Views field of the topic table
- This is the basic implementation process
- In the above, we found that the views will not be stored directly into the topic table. The advantage of this is to prevent frequent updates to the topic table and prevent the table from being locked.
preventrefresh value controls whether it is turned on or not. To optimize the number of topic views, 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 we continuously improve ourselves.The above is the detailed content of Discuz theme views implementation principle and solution to non-updating. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The solution to the Discuz background login problem is revealed. Specific code examples are needed. With the rapid development of the Internet, website construction has become more and more common, and Discuz, as a commonly used forum website building system, has been favored by many webmasters. However, precisely because of its powerful functions, sometimes we encounter some problems when using Discuz, such as background login problems. Today, we will reveal the solution to the Discuz background login problem and provide specific code examples. We hope to help those in need.

"Detailed Explanation of Discuz Registration Process: Allowing you to easily modify personal information, specific code examples are required" Discuz is a powerful community forum program that is widely used in various websites. It provides a wealth of user registration and personal information modification. functions and interfaces. This article will introduce you to Discuz's registration process in detail and provide specific code examples to help you easily customize and modify your personal information. 1. User registration process In Discuz, user registration is one of the important functions of the site. The smoothness of the registration process and

"Exploring Discuz: Definition, Functions and Code Examples" With the rapid development of the Internet, community forums have become an important platform for people to obtain information and exchange opinions. Among the many community forum systems, Discuz, as a well-known open source forum software in China, is favored by the majority of website developers and administrators. So, what is Discuz? What functions does it have, and how can it help our website? This article will introduce Discuz in detail and attach specific code examples to help readers learn more about it.

A must-have for Discuz users! Comprehensive analysis of renaming props! In the Discuz forum, the name change function has always received much attention and demand from users. For some users who need to change their name, name change props can easily modify the user name, and this is also an interesting way of interaction. Let’s take an in-depth look at the renaming props in Discuz, including how to obtain them, how to use them, and solutions to some common problems. 1. Obtain name-changing props in Discuz. Name-changing props are usually purchased through points or the administrator

What should I do if I encounter an incorrect Discuz password? Quick solution sharing! Discuz! It is a very popular forum program that provides users with a platform for convenient communication. Using Discuz! When accessing a forum, sometimes you may encounter an incorrect password, which may cause users to be unable to log in and use the forum normally. Well, meet Discuz! When the password is wrong, how should we quickly solve the problem? Some solutions will be shared below, with specific code examples provided for reference. 1. Check whether the password

Title: To solve the problem that Discuz WeChat shares cannot be displayed, specific code examples are needed. With the development of the mobile Internet, WeChat has become an indispensable part of people's daily lives. In website development, in order to improve user experience and expand website exposure, many websites will integrate WeChat sharing functions, allowing users to easily share website content to Moments or WeChat groups. However, sometimes when using open source forum systems such as Discuz, you will encounter the problem that WeChat shares cannot be displayed, which brings certain difficulties to the user experience.

Discuz Editor: A powerful web page editing tool that requires specific code examples. With the development of the Internet, website construction and content editing have become more and more important. As a common web page editing tool, Discuz editor plays an important role in website construction. It not only provides a wealth of functions and tools, but also helps users edit and publish content more conveniently. In this article, we will introduce the features and usage of the Discuz editor, and provide some specific code examples to help readers better understand and use

Title: Discuz background account login exception, how to deal with it? When you use the backend management of the Discuz forum system, you may sometimes encounter abnormal account login. This could be due to a variety of reasons, including a wrong password, account being blocked, network connection issues, etc. When encountering this situation, we need to solve the problem through simple troubleshooting and processing. Check whether the account number and password are correct: First, confirm whether the account number and password you entered are correct. When logging in, make sure the capitalization is correct and the password is
