您现在的位置:
主页 >
帮助中心 >
织梦教程 > DedeCMS文章列表页自动统计当前栏目文档总数的方
实现这个功能有两种具体的方法:
第一种:runphp=’yes’
利用织梦自带的runphp参数来实现这个功能,只需要在您需要显示统计数量的地方直接加入以下代码
-
{dede:field.typeid runphp='yes'}
-
global $dsql;
-
$row = $dsql->GetOne("select count(*) as dd from dede_archives where typeid = @me");
-
@me = $row['dd'];
-
{/dede:field.typeid}
第二种:function
我们通常所说的函数,在织梦(DedeCMS)中,我们可以利用自定义函数来实现各种效果,实现的具体方法为:
在/include/extend.func.php文件的?>上一行加入以下代码:
-
function _GetTypeNum($tid){
-
global $dsql;
-
$row = $dsql->GetOne("select count(*) as dd from dede_archives where typeid = $tid");return $row['dd'];
-
}
在模板需求统计栏目文档的地方加入以下代码:
-
{dede:field.typeid function="GetTypeNum(@me)"/