dedecms子栏目中调用其顶级栏目名称和简介的方法
脚本之家
本文实例讲述了dedecms子栏目中调用其所属顶级栏目的名称和简介的方法。分享给大家供大家参考。具体实现方法如下:
顶级栏目的名称及链接:
{dede:field name='id' runphp="yes"}
global $cfg_basehost,$cfg_cmspath,$cfg_indexurl;
$dsql = new DedeSql(false);
$a="SELECT tp.reid FROM dede_arctype as tp where tp.id=@me";
$arcRow = $dsql->GetOne($a);
@me="$arcRow[reid]";
if(@me==0)@me='首页';
else {$b="SELECT * FROM dede_arctype as tp where tp.id=@me";
$tpRow = $dsql->GetOne($b);
@me=''.$tpRow[typename].'';
$url=$cfg_basehost.$cfg_cmspath;
@me=str_replace('{cmspath}',$url,@me);
}
$dsql->Close();
{/dede:field}
global $cfg_basehost,$cfg_cmspath,$cfg_indexurl;
$dsql = new DedeSql(false);
$a="SELECT tp.reid FROM dede_arctype as tp where tp.id=@me";
$arcRow = $dsql->GetOne($a);
@me="$arcRow[reid]";
if(@me==0)@me='首页';
else {$b="SELECT * FROM dede_arctype as tp where tp.id=@me";
$tpRow = $dsql->GetOne($b);
@me=''.$tpRow[typename].'';
$url=$cfg_basehost.$cfg_cmspath;
@me=str_replace('{cmspath}',$url,@me);
}
$dsql->Close();
{/dede:field}
栏目描述:
{dede:field name='id' runphp="yes"}
$dsql = new DedeSql(false);
$a="SELECT tp.reid FROM dede_arctype as tp where tp.id=@me";
$arcRow = $dsql->GetOne($a);
@me="$arcRow[reid]";
if(@me==0)@me='';
else {$b="SELECT * FROM dede_arctype as tp where tp.id=@me";
$tpRow = $dsql->GetOne($b);
@me=$tpRow[description];
$dsql->Close();
{/dede:field}
$dsql = new DedeSql(false);
$a="SELECT tp.reid FROM dede_arctype as tp where tp.id=@me";
$arcRow = $dsql->GetOne($a);
@me="$arcRow[reid]";
if(@me==0)@me='';
else {$b="SELECT * FROM dede_arctype as tp where tp.id=@me";
$tpRow = $dsql->GetOne($b);
@me=$tpRow[description];
$dsql->Close();
{/dede:field}
希望本文所述对大家的dedecms建站有所帮助。