Pursuing a dream Dede article page article calling Views

Use  when dedecms station, in the information page article page article calling given official visits labels are:

  1. {dede:field.click/}
 

This label is called static views, that is, the views of our randomly generated when generating article, no matter how refreshing here in the article page will not increase visits, the user experience is very bad.
There are solutions online, that is calling for the label change:

  1. <script src="{dede:field name='phpurl'/}/count.php?view=yes&aid={dede:field name='id'/}&mid={dede:field name='mid'/}&cid={dede:field name='channel'/}" type='text/javascript' language="javascript"></script>

So to be able to achieve the number of dynamic invocation Post Views, refresh increased once, but after using it found a problem, every time the page is loaded into this place will look Caton, because this is js call, every time a request to the server once the label here is timely loaded here will certainly Caton, gives an optimal solution after the study. Specific ideas for: We can be customized to a digital (defined by more than the bucket is 0). When the first page to load, load our prior booking is a good number, then call the real clicks through the last page load JS. Specific steps:
1, in the position of clicks a span defined by a number of clicks

  1. <span id="countnum">0</span>次

2, modify Dede core function, find the plus / count.php in

  1. echo "document.write('".$row['click']."');\r\n";

Probably 25 lines, replaced

  1. echo 'document.getElementById("countnum").innerHTML='.$row['click'];

3, at the bottom of the page to add js code

  1. <script src="{dede:field name='phpurl'/}/count.php?view=yes&aid={dede:field name='id'/}&mid={dede:field name='mid'/}" type='text/javascript' language="javascript"></script>

Js at the bottom of the page will be able to add the perfect solution when loaded Views Caton problem with the use of a very good experience, so far, to achieve the article page dynamically invoke article views.

Guess you like

Origin www.cnblogs.com/pz777/p/11796099.html