{dede:field name='typeid' runphp='yes'}
global $dsql;
$tid=(int)$DedeMeValue;
$rootId=$tid;
$cur=$dsql->GetOne("SELECT id,reid FROM `#@__arctype` WHERE id='$tid'");
if(is_array($cur)){
$cnt=$dsql->GetOne("SELECT COUNT(*) AS c FROM `#@__arctype` WHERE reid='{$tid}' AND ishidden=0");
if(!is_array($cnt)||$cnt['c']<2) $rootId=(int)$cur['reid'];
}
$root=$dsql->GetOne("SELECT id,typename FROM `#@__arctype` WHERE id='$rootId'");
if(is_array($root)){
$h='
';
$act=($tid==$rootId)?' active':'';
$h.=''.$root['typename'].'';
$dsql->Execute('cattab',"SELECT id,typename FROM `#@__arctype` WHERE reid='$rootId' AND ishidden=0 ORDER BY sortrank ASC");
while($s=$dsql->GetArray('cattab')){
$act=($tid==$s['id'])?' active':'';
$h.=''.$s['typename'].'';
}
$h.='
';
$DedeMeValue=$h;
}else{ $DedeMeValue=''; }
{/dede:field}