在一次偶然的机会遇到客户需要在内容页面调用当前内容所在的栏目名称,但是不想要链接(要链接就没下面这么多事了),所以只好做如下修改:
phpcms\libs\functions\global.func.php
里面增加
function lanmu($catid, $symbol=' > '){
$category_arr = array();
$siteids = getcache('category_content','commons');
$siteid = $siteids[$catid];
$category_arr = getcache('category_content_'.$siteid,'commons');
if(!isset($category_arr[$catid])) return '';
$pos = '';
$siteurl = siteurl($category_arr[$catid]['siteid']);
$arrparentid = array_filter(explode(',', $category_arr[$catid]['arrparentid'].','.$catid));
foreach($arrparentid as $catid) {
$url = $category_arr[$catid]['url'];
if(strpos($url, '://') === false) $url = $siteurl.$url;
$pos .= ''.$category_arr[$catid]['catname'].'';
}
return $pos;
}
调用方式:
{lanmu($catid)}
感谢分享!超级赞!
还是不行?