//当前位置-第一个参数 catid为当前栏目的id,第二个参数为文章的标题,调用栏目当前位置时第二个参数为空即可。
$this->assign("now_here",$this->now_here($catid,$res['title']));
//代码如下:
//解释一下,栏目表category中的catid为栏目id,catname为栏目名称,asmenu为栏目父级的id,当为顶级栏目时,
//asmenu为0 。
protected function now_here($catid,$ext=''){
$cat = M("Category");
$here = '/">首页';
$uplevels = $cat->field("catid,catname,asmenu")->where("catid=$catid")->find();
if($uplevels['asmenu'] != 0)
$here .= $this->get_up_levels($uplevels['asmenu']);
if($ext != '') $here .= ' -> '.$ext;
return $here;
}
protected function get_up_levels($id){
$cat = M("Category");
$here = '';
$uplevels = $cat->field("catid,catname,asmenu")->where("catid=$id")->find();
if($uplevels['asmenu'] != 0){
$here = $this->get_up_levels($uplevels['asmenu']).$here;
}
return $here;
}