最近在做一个网站用到副栏目的调用,在网上搜了一下,没有找到一个好的方法,于是自己写了一个,希望能够帮到大家。
方法一:
内容页的调用写法:
{dede:field.typeid2 runphp='yes'}
global $dsql;
$ks = split(',', @me);
$tname="";
foreach($ks as $k){
$k = trim($k);
if ($k!="") {
if ($row = $dsql->getOne("select *,ID as id1 from dede_arctype where id=".$k)){
$mpath=GetTypeUrl($row['id1'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],
$row['ispart'],$row['namerule2'],$row['siteurl']);
$tname.="<span><a href='{$mpath}'>".$row['typename']."</a></span>";
}
}
}
@me=substr($tname,0,strlen($tname)-1);
{/dede:field.typeid2
首页、列表页标签(在arclist、list等文章列表标签里用):
[field:typeid2 runphp='yes']
global $dsql;
$ks = split(',', @me);
$tname="";
foreach($ks as $k){
$k = trim($k);
if ($k!="") {
if ($row = $dsql->getOne("select *,ID as id1 from dede_arctype where id=".$k)){
$mpath=GetTypeUrl($row['id1'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],$row['ispart'],
$row['namerule2'],$row['siteurl']);
$tname.="<span><a href='{$mpath}'>".$row['typename']."</a></span>";
}
}
}
@me=substr($tname,0,strlen($tname)-1);