织梦获取顶级栏目链接,名称及id方法

织梦获取当前页面的顶级栏目名称及链接教程,Dedecms获取顶级栏目id,织梦dede调用当前顶级栏目名称、ID、url方法,详解织梦调用当前顶级栏目名称、ID、url方法,下面小编来给大家介绍一下,一起来了解一下吧!

织梦顶级栏目链接,名称及id调用代码 

 {dede:field.typeid function="gettoptype(@me,typename)"/} //名称 

 {dede:field.typeid function="gettoptype(@me,typeurl)"/}//链接 

修改 include/helpers/extend.helper.php 
 
结尾增加 :

 /*  获取顶级栏目相关信息
  *
  * @access    public
  * @param     string  $tid  栏目id
  * @param     string  $field栏目字段
  * @return    string
  */
 if ( ! function_exists('getToptype'))
 {
 function getToptype($tid,$field)
 {
 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 `dede_arctype` WHERE id=$topid");
 if($field=='id') return $topid;
 if($field=='typename') return $row['typename'];//栏目名称
 if($field=='typeurl') return GetOneTypeUrlA($row);//栏目链接
 if($field=='typenamedir') return $row['typenamedir'];//栏目英文名称
 if($field=='seotitle') return $row['seotitle'];//栏目SEO标题
 if($field=='description') return $row['description'];//栏目描述
 if($field=='content') return $row['content'];//栏目内容
 }
 }

更多教程关注FF推源码网。

提供最优质的资源集合

立即查看 了解详情