Home > CMS Tutorial > DEDECMS > body text

How to use JS to call the total number of comments in DEDECMS

藏色散人
Release: 2019-12-20 10:27:00
Original
1854 people have browsed it

How to use JS to call the total number of comments in DEDECMS

How does DEDECMS use JS to call the total number of comments?

The website is being revised. The total number of comments in DEDE is static now. It would be too resource-intensive to update the HTML for each comment. Many friends on the forum have not solved it. I did some research and used it. The JS method call only queries one field. It should not waste resources. This needs to be tested. It shouldn't take up resources.

Recommended learning: 梦Weavercms

The method is as follows. It is divided into two steps.

1. Create a new fedcount.php file under PLUS with the following content

The code is as follows:

document.writeln("共有 <?php 
require(dirname(__FILE__)."/../include/config_base.php"); 
$db = new DedeSql(false); 
$rs = $db->GetOne("SELECT postnum FROM dede_archives WHERE ID=&#39;{$aid}&#39;"); 
if(!is_array($rs)){ 
echo "0"; 
}else { 
echo $rs[&#39;postnum&#39;]; 
} 
?>位网友发表了评论");
Copy after login

2. Insert the following code into the content page template

The code is as follows:

<script type="text/javascript" src="/plus/fedcount.php?aid={dede:field name=ID/}"></script>
Copy after login

Generate and you can see the effect displayed in real time.

Whether it takes up resources or not, let’s test it with friends and give feedback after using it.

If it takes up resources, then clear the contents of fedcount.php

This way, without querying the database, it will definitely not take up resources, haha.

The above is the detailed content of How to use JS to call the total number of comments in DEDECMS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!