织梦获取当前页面的顶级栏目名称及链接方法:在织梦文件目录中打开 includeextend.func.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'];//栏目内容 } }
在织梦模板中调用以下代码:
{dede:field.typeid function=getToptype(@me,typename)/}
{dede:field.typeid function=getToptype(@me,typeurl)/}获取顶级栏目链接,{dede:field.typeid function=getToptype(@me,typename)/}是获取顶级栏目名称。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)