在方法application文件里面的function.php加上一个函数:
function getposition($id){
$path = M('terms')->where(array('term_id'=>$id))->getField('path'); $str = '';
if(!empty($path)){
$path = explode('-', $path);
foreach ($path as $key => $value) {
if($value==0){
$str = $str . '<a href="' . __ROOT__ . '">首页</a><i class="iconfont"></i>'; }
else{
$name = M('terms')->where(array('term_id'=>$value))->getField('name');
$str = $str . '<a href="' . __ROOT__ . '">' . $name . '</a><i class="iconfont"></i>';
}
}
}
return $str;
}
在文章页页面加上{:getposition($term_id)}就可以了。