如何让织梦 channel和channelartlist 调用栏目的文章数量?元素模板YS720.COM为您解答
修改方式:
打开include/common.func.php文件,在最后面添加方法:
/**
* 统计栏目文章数
**/
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'];
}
调用方法:
一级栏目调用channelartlist:
{dede:field.typeid function="GetTotalArc(@me)"/}
二级栏目调用channel:
[field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID]
HTML实例代码:
<ul class="nav bg" data-ride="collapse">
<li class="hidden-nav-xs padder m-t m-b-sm text-xs text-muted">
素材
</li>
<!-- 界面| -->
{dede:channelartlist typeid='26,39,40'}
<li >
<a href="{dede:field name='typeurl'/}" class="auto">
<span class="pull-right text-muted">
<i class="fa fa-angle-left text"></i>
<i class="fa fa-angle-down text-active"></i>
</span>
<i class="
{dede:global runphp='yes' name=itemindex }
if(@me==1) @me='fa fa-mobile text-primary-lter phone';
else if(@me==2) @me='icon-screen-desktop icon text-primary-lter';
else if(@me==3) @me='fa fa-underline icon text-primary-lter';
else if(@me==4) @me='icon-social-dropbox text-primary-lter';
{/dede:global}">
</i>
<b class="badge bg-primary pull-right font-thin">{dede:field.typeid function="GetTotalArc(@me)"/}</b>//总数
<span>{dede:field name='typename'/}</span>
</a>
<ul class="nav dk text-sm">
{dede:channel type='sun'}
<li >
<a href="[field:typelink/]" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<b class="badge bg-info pull-right font-thin">[field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID]</b>//总数
<span>[field:typename/]</span>
</a>
</li>
{/dede:channel}
</ul>
</li>
{/dede:channelartlist}
<!--/ 界面| -->
</ul>
<!--/ 素材 -->