每一个你不满意的现在,都有一个你不努力的曾经. 网站首页 > php
thinkPHP制作面包屑方法
        发布时间:2018-12-11 12:23:00
        修改时间:2019-01-03 14:46:11
        
        阅读:5720
        评论:0
        
0
    
//当前位置-第一个参数 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']);
   $here .= ' -> '.$uplevels['catname']."";
   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();
   $here .= ' -> '.$uplevels['catname']."";
   if($uplevels['asmenu'] != 0){
      $here = $this->get_up_levels($uplevels['asmenu']).$here;
   }
   return $here;
}
回复列表
关键字词:code,nbsp,style,gt,here,catid
上一篇:css常用属性
