How to count the number of column articles in dede?
Method 1:
Recommended learning:Dream Weaver cms
Involved files: include/common. func.php
Add the following code at the bottom of include/common.func.php before ?>
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']; }
Calling method:
The code is as follows:
[field:ID function='GetTotalArc(@me)'/] 或 [field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID]
For example, add the following code to your homepage template:
The code is as follows:
共{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 one: Open the include/common.func.php file and add it before the last ?> :
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']; } //统计结束
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, on the home page template Column name ({dede:field name='typename'/})
Add the following code after:
The code is as follows:
{dede:type}[field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID]{/dede:type}
The above is the detailed content of How to count the number of column articles in dede. For more information, please follow other related articles on the PHP Chinese website!