早唞 發表於 2023-8-1 00:00:00

dedecms织梦模板栏目列表中添加统计文档数量的标签

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        dedecms在栏目列表中添加统计文档数量调用标签,实现的方法还是非常简单的,只需要做一些简单的修改即可实现我们所需要的功能。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        方法如下:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        打开include/extend.func.php文件,在最后一行?的上面添加以下内容:</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:php;toolbar:false;">
function GetTotalArc($tid){
global $dsql;
$sql = GetSonIds($tid);
$row = $dsql-&gt;GetOne("Select count(id) as dd From dede_archives where typeid in({$sql})");
return $row['dd'];   }

</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        下面是我添加的示例代码,供大家参考!</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:php;toolbar:false;">
&lt;?php
function litimgurls($imgid=0){
   global $lit_imglist;
   $dsql = new DedeSql(false);
   //获取附加表
   $row = $dsql-&gt;GetOne("SELECT c.addtable FROM dede_archives AS a LEFT JOIN dede_channeltype AS c ON a.channel=c.id where a.id='$imgid'");
   $addtable = trim($row['addtable']);
   //获取<u>图片</u>附加表imgurls字段内容进行处理
   $row = $dsql-&gt;GetOne("Select imgurls From `$addtable` where aid='$imgid'");
   //调用inc_channel_unit.php中ChannelUnit类
   $ChannelUnit = new ChannelUnit(2,$imgid);
   //调用ChannelUnit类中GetlitImgLinks方法处理缩略图
   $lit_imglist = $ChannelUnit-&gt;GetlitImgLinks($row['imgurls']);
   //返回结果
   return $lit_imglist;
}

// 文档数量调用标签

function GetTotalArc($tid){
global $dsql;
$sql = GetSonIds($tid);
$row = $dsql-&gt;GetOne("Select count(id) as dd From dede_archives where typeid in({$sql})");
return $row['dd'];   
}   
?&gt;

</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        针对arclist与list模板代码的调用方法:</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:xhtml;">
</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        其它位置的使用代码的调用方法:</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:xhtml;">
@me = GetTotalArc(@me);</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        运行之后的效果截图如下:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei"; text-align: center;'>
        <img style="max-width:100%!important;height:auto!important;"title="dedecms织梦模板栏目列表中添加统计文档数量的标签" alt="dedecms织梦模板栏目列表中添加统计文档数量的标签" src="https://zhuji.jb51.net/uploads/img/202305/8ba9c19ff61b026f7c67a1ecff33c416.jpg"></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁: [1]
查看完整版本: dedecms织梦模板栏目列表中添加统计文档数量的标签