今天小编给出一个函数,解决织梦获取当前栏目的顶级栏目的办法,找到织梦里的include/extend.func.php 加入如下函数:
01function GetTopTypeName($typeid)02{03 global $dsql;04 $typeRow = $dsql->GetOne("SELECT typename,topid FROM dede_arctype WHERE id= $typeid");05 if ($typeRow['topid'] == '0')06 {07 return $typeRow['typename'];08 }09 else10 {11 $typeRow1 = $dsql->GetOne("SELECT typename FROM dede_arctype WHERE id= $typeRow[topid]");12 return $typeRow1['typename'];13 }14}
然后在模板里面通过标签{dede:field.typeid function=“GetTopTypeName(@me)”}即可