织梦dedecms里如何调用父级栏目的ID
{dede:field name='typeid' runphp='yes'}
global $dsql;
/获取当前栏目id/
$typeid = @me;
$query = "SELECT reid FROM dede_arctype where id = $typeid";
$rs = $dsql->GetOne($query);
$reid = $rs['reid'];//获取到栏目的上级栏目
/获取上级栏目id/
$query2 = "SELECT FROM dede_arctype where id = $reid";
$typerow = $dsql->GetOne($query2);
/输出上级栏目信息/
$typename = $typerow['typename'];
$link = GetTypeUrl($typerow['typeid'],MfTypedir($typerow['typedir']),$typerow['isdefault'],$typerow['defaultname'],$typerow['ispart'],$typerow['namerule2'],$typerow['moresite'],$typerow['siteurl'],$typerow['sitepath']);
@me = "<a href='/{$link}'>$typename</a>";
{/dede:field}
你好,根据你提的问题找到相关的解决方法,你可以参考一下
第一种:根据所在栏目ID自动判断显示所在栏目的文章数
(<span>[field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID]</span>)第二种:指定栏目ID
{dede:sql sql="SELECT count( ID ) AS c FROM dede_archives where typeid = 栏目id "}第三种:DedeCMS栏目文章数量统计调用,栏目名称按照文章数量排列
{dede:sql sql='SELECT dtypename,did,count(daid) as heji FROM dede_arctype d left joindede_archives da on datypeid=did where dreid=0 group by dtypename order by heji desc limit 0,8;'}
<span class="text_1"><span class="count">[[field:heji/]篇]</span>
<a href="http://你的网址/plus/listphptid=[field:id/]">[field:typename/]共投递稿件</a></span><br />
{/dede:sql}
第四种: 修改include/commonfuncphp 在最后加入代码:
//统计栏目文章数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']; }
在htm 最下方添加:
{dede:channel type='top' row='8'}
<LI>[field:typename/]
(<span>[field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID]</span>)
</LI>
{/dede:channel}
如果想调用副栏目的数量 就是
//统计栏目文章数
function GetTotalArc($tid2){
global $dsql;
$sql = GetSonIds($tid2);
$row = $dsql->GetOne("Select count(id) as dd From dede_archives where typeid2 in({$sql})");
return $row['dd']; }
HTM页面不变 现在我们来说说动态调用栏目文章数:
动态调用主要针对当前列表页的栏目,而当前的栏目是动态的,因此可以利用type标签调用一个函数就行了。
要调用函数就得增加函数,打开include/commonfuncphp,在其中任一行(<与>的中间任一行)中加上如下函数。
function dynamic_num($current_id){global $dsql; $t_num = $dsql->GetOne("select count() as num from `dede_archives` where typeid='$current_id'");
if(is_array($t_num))
{
return "本栏目共有"$t_num[num]"篇文章"; }
else{
return "本栏目共有0篇文章" ; }
}
在列表页中这样调用:
{dede:type}[field:id function="dynamic_num(@me)" /]{/dede:type}{dede:sql sql="SELECT count( ) AS c FROM cmsxx_archives WHERE pubdate > UNIX_TIMESTAMP( CURDATE( ) ) "}
<li class="count">今日更新:<span>[field:c/]</span> 篇</li>
{/dede:sql}
{dede:sql sql="Select count(ID) as c From cmsxx_archives WHERE FROM_UNIXTIME(pubdate,'%m')=month(curdate())"}
<li class="count">当月更新:<span>[field:c/]</span> 篇</li>
{/dede:sql}
{dede:sql sql="select count() as c from cmsxx_archives}
<li class="count">共有文章:<span>[field:c/]</span> 篇</li>
{/dede:sql}
{dede:sql sql="select sum(click) as c from cmsxx_archives"}
<li class="count">总共阅读:<span>[field:c/]</span> 人次</li>
{/dede:sql}
{dede:sql sql="select count(mid) as c from cmsxx_member "}
<li class="count">共有会员:<span>[field:c/]</span> 名</li>
{/dede:sql}
还可以指定栏目ID,例如:
{dede:sql sql="select count() as c from cmsxx_archives where channel in(1,2,3,5,6,9)"}<li class="count">共有文章:<span>[field:c/]</span> 篇</li>
{/dede:sql}
希望以上方法能够帮助到你。
GetParentId(@me)
<img src="{dede:globalcfg_templets_skin/}/webimg/leftmenu_title_{dede:fieldtypeid function="GetParentId(@me)"/}png" width="240" height="56" />
0条评论