Optimized calling code for calling article views on the page of weaving dreams

When using Dream Weaving to build a website, on the information page of the article page, the official label for calling the number of article views is:

{dede:field.click/}

This tag calls the number of static views, which is the number of randomly generated views when we generate the article. No matter how the article page is refreshed, the number of views will not increase, and the user experience is very poor.

There is a solution on the Internet, that is, to change the call label to:

In this way, you can dynamically call the number of article views, refresh once and increase it once, but after using it, a problem is found. Every time the page is loaded to this place, it will be stuck, because here is a js call, which requires a request from the server every time Once, the label here is loaded in time, and it will definitely get stuck here. After research, an optimal solution will be given.

The specific idea is: we can customize a number first (it can be defined as 0). When the web page is loaded first, it loads the number that we pre-determined, and then calls the actual number of clicks through the last loading JS of the web page. The specific steps are:

1. Use the span tag to define a number of clicks in the position of the number of clicks

0 times

2. Modify the Dede core function and find it in plus/count.php

echo “document.write(’”.$row[‘click’]."’);\r\n";

Approximately on line 25, replace it with

echo ‘document.getElementById(“countnum”).innerHTML=’.$row[‘click’];

3. Add js code at the bottom of the page

Guess you like

Origin blog.csdn.net/a9490489/article/details/114236121