免费html网站模板

织梦获取上级栏目ID及顶级栏目ID

织梦cms教程 2020-11-24 06:01:47

上级栏目ID{dede:field.reid/}顶级栏目ID{dede:field.typeid function='GetTopid(@me)'/}Dedecms获取顶级栏目id,名称及链接{dede:field.typeid function=gettoptype(@me,id)/} //id{dede:field.typeid function=gettoptype(@me,name)/} //名称{dede:field.typeid function=gettoptype(@me,link)/} //链接修改 include/helpers/extend.helper.php结尾增加 :/*** 获取一个类目的顶级栏目* @param string $tid 栏目ID* @return string*/if ( ! function_exists('gettoptype')){function gettoptype($tid,$action){global $dsql,$cfg_Cs;if(!is_array($cfg_Cs)){require_once(DEDEDATA./cache/inc_catalog_base.inc);}if(!isset($cfg_Cs[$tid][0]) || $cfg_Cs[$tid][0]==0){$topid = $tid;}else{$topid = GetTopid($cfg_Cs[$tid][0]);}$row = $dsql-GetOne(SELECT * FROM `arctype` WHERE id=$topid);$toptypename = $row['typename'];$toptypeurl = $topid;if($action=='id') return $topid;if($action=='name') return $toptypename;if($action=='link') return GetOneTypeUrlA($row);}}