dede当前顶级栏目没有下级栏目就显示顶级栏目
dede当前顶级栏目没有下级栏目就显示顶级栏目
操作方法
- 01
{dede:php} $dsql->safeCheck = false; if($refObj->Fields['topid'] == 0){ $typeid = $refObj->Fields['typeid']; $row = $dsql->GetOne("select count(*) as count from dede_arctype where topid = $typeid"); if($row['count']<=0){ $sql = "select * from #@__arctype where topid = 0"; $dsql->Execute("me",$sql); while($arr = $dsql->GetArray('me')){ $typedir = str_replace("{cmspath}",'',$arr['typedir']); $typename = $arr['typename']; echo "<a href='$typedir' target='_blank'>$typename</a>"; } } } {/dede:php}
- 02
<div class="left-nav"> {dede:channel row='20' currentstyle="<a href='~typelink~' class='active' target='_self'>~typename~</a></li>"} <a href='[field:typeurl/]' title="[field:typename/]">[field:typename/]</a> {/dede:channel} {dede:php} $dsql->safeCheck = false; if(!isset($refObj->Fields['writer']) && ($refObj->Fields['reid'] == "0" || $refObj->Fields['topid'] == "0")){ $typeid = $refObj->Fields['typeid']; $row = $dsql->GetOne("select count(*) as count from dede_arctype where topid = $typeid"); if($row['count']<=0){ $sql = "select * from #@__arctype where topid = 0"; $dsql->Execute("me",$sql); while($arr = $dsql->GetArray('me')){ $typedir = str_replace("{cmspath}",'',$arr['typedir']); $typename = $arr['typename']; if($arr['id'] != $typeid){ if($arr['id'] == 41){ continue; } echo "<a href='$typedir' title='$typename'>$typename</a>"; } } } } {/dede:php} </div>