原文来自:https://www.zixuephp.com
dedecms获取当前栏目的顶级栏目名称
模板中用 {dede:field.typeid function="GetTopname(@me)"/} 调用,include\helpers\channelunit.helper.php 末尾增加:
- if(!function_exists('GetTopname'))
- {
- functionGetTopname($tid)
- {
- global$dsql,$cfg_Css;
- if(!is_array($cfg_Css))
- {
- require_once(DEDEDATA."/cache/inc_catalog_base.inc");
- }
- $row=$dsql->GetOne("SELECT*FROM`detest_arctype`WHEREid=$tid");
- $toptypename=$row['typename'];
- $reid=$row['reid'];
- if($reid==0){
- return$toptypename;
- }
- else{
- $row=$dsql->GetOne("SELECT*FROM`detest_arctype`WHEREid=$reid");
- $toptypename=$row['typename'];
- return$toptypename;
- }
- }
- }