The method of counting the number of column articles in dede
This article mainly introduces the method of counting the number of articles in dede, which has a certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
How to count the number of column articles in dede?
Method 1:
Files involved: include/common.func.php
Add the following code before the bottom of the include/common.func.php, that is,? >
The code is as follows:
Function GetTotalArc ($tid) {global $dsql; $sql = GetSonIds ($tid); $row = $dsql- > GetOne ("Select count (id) as dd From dede_archives where typeid in ({$sql})"); return $row ['dd'];}
Call method:
The code is as follows:
[field:ID function='GetTotalArc (@ me)'/] or [field:ID runphp='yes'] @ me = GetTotalArc (@ me); [/ field:ID]
For example, add the following code to your home page template:
The code is as follows:
Total {dede:type} [field:ID function='GetTotalArc (@ me)'/] {/ dede:type}
Or add the following code after the column name:
({dede:type} [field:ID function='GetTotalArc (@ me)'/] {/ dede:type})
Method 2:
Step 1: open the include/common.func.php file and add the following before the last? >
The code is as follows:
/ / number of articles in statistics column function GetTotalArc ($tid) {global $dsql; $sql = GetSonIds ($tid); $row = $dsql- > GetOne ("Select count (id) as dd From dede_archives where typeid in ({$sql})"); return $row ['dd'];} / / end of statistics
Step 2: you can use the following code on the template
The code is as follows:
{dede:channel type='top' typeid=''} [field:typename/] ([field:ID runphp='yes'] @ me = GetTotalArc (@ me); [/ field:ID]) {/ dede:channel}
For example, the column name ({dede:field name='typename'/}) on the home page template
The following code is added later:
The code is as follows:
{dede:type} [field:ID runphp='yes'] @ me = GetTotalArc (@ me); [/ field:ID] {/ dede:type} Thank you for reading this article carefully. I hope it will be helpful for the editor to share the number of articles in the dede column. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find a detailed solution waiting for you to learn!