DedeCMS默认在栏目列表页没有调用当前栏目文章数量的标签,但有时候我们做网站时又需要调用这个数量。
下面就告诉大家两种方法:
第一种方法:修改include/inc_arcpart_view.php文件
找到
function ParseTemplet()函数
修改为:
function ParseTemplet() { if(!is_array($this->dtp->CTags)) return ""; foreach($this->dtp->CTags as $tagid=>$ctag) { $tagname = $ctag->GetName(); //countclass 统计栏目文章数量 if( $tagname == "countclass" ){ $tid = $ctag->GetAtt("typeid"); $row = $this->dsql->GetOne("Select count(ID) as dd From tufei_archives where typeid='$tid' and arcrank<>-1"); $this->dtp->Assign($tagid,$row['dd']); }
调用标签:
{dede:countclass typeid=栏目ID/}
例如:
{dede:countclass typeid='2'/}
第二种方法:修改include/inc_functions.php文件,增加函数如下:
function GetTotalArc($tid){ $dsql = new DedeSql(false); $row = $dsql->GetOne("Select count(ID) as dd From tufei_archives where typeid='$tid'"); return $row['dd']; }
调用标签:
[field:id function='GetTotalArc(@me)'/]
这样就能统计并显示栏目内容数量了
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)