DEDECMS模板织梦CMS增加统计栏目文章数的代码课程

2021-10-10 作者:未知   |   浏览(
-->达成办法:
打开include/common.func.php文件,在最下面加入以下代码:
//统计栏目文章数开始
function GetTotalArc{global $dsql;$sql = GetSonIds;$row = $dsql->GetOne as dd From dede_archives where typeid in");return $row['dd'];}

//统计栏目文章数结束
调用办法:
[field:ID function='GetTotalArc'/]//此中调用当栏目下无文章时显示"空"

[field:ID runphp='yes'] @me = GetTotalArc;[/field:ID]//此中调用当栏目下无文章时显示"0"
示例:
调用指定栏目ID的栏目文章数:
{dede:type typeid='1'}[field:typename/]([field:ID function='GetTotalArc'/]){/dede:type}
{dede:type typeid='1'}[field:typename/]([field:ID runphp='yes'] @me = GetTotalArc;[/field:ID]){/dede:type}
调用顶级栏目的栏目文章数:
{dede:channel type='TOP' row='10' current}<li><a href='[field:typeurl/]' [field:rel/]><span>[field:typename/]([field:ID function='GetTotalArc'/])</span></a></li>{/dede:channel}{dede:channel type='TOP' row='10' current}<li><a href='[field:typeurl/]' [field:rel/]><span>[field:typename/]([field:ID runphp='yes'] @me = GetTotalArc;[/field:ID])</span></a></li>{/dede:channel}

调用某一栏目下子栏目的文章数:
{dede:channeltype ='son' typeid ='1' row='10' current}<li><a href='[field:typeurl/]' [field:rel/]><span>[field:typename/]([field:ID function='GetTotalArc'/])</span></a></li>{/dede:channel}{dede:channel type ='son' typeid ='1' row='10' current}<li><a href='[field:typeurl/]' [field:rel/]><span>[field:typename/]([field:ID runphp='yes'] @me = GetTotalArc;[/field:ID])</span></a></li>{/dede:channel}

文章页/栏目页调用目前栏目的文章数:
{dede:type}[field:typename/]([field:ID function='GetTotalArc'/]){/dede:type}{dede:type}[field:typename/]([field:ID runphp='yes'] @me = GetTotalArc;[/field:ID]){/dede:type}