thinkphp3.2 获取当前位置的解决方法

来源:互联网 发布:食药局数据查询 编辑:程序博客网 时间:2024/06/06 07:05

写一个全局公共函数!代码如下:


function now_here($catid,$ext=''){$cat = M("Category");$here = '<a href="'.__ROOT__.'">首页</a>';$uplevels = $cat->field("catid,catname,asmenu")->where("catid=$catid")->find();if($uplevels['asmenu'] != 0)$here .= get_up_levels($uplevels['asmenu']);$here .= ' -> <a href="/cat_'.$uplevels['catid'].'.html">'.$uplevels['catname']."</a>";if($ext != '') $here .= ' -> '.$ext;return $here;}function get_up_levels($id){$cat = M("Category");$here = '';$uplevels = $cat->field("catid,catname,asmenu")->where("catid=$id")->find();$here .= ' -> <a href="/cat_'.$uplevels['catid'].'.html">'.$uplevels['catname']."</a>";if($uplevels['asmenu'] != 0){$here = $this->get_up_levels($uplevels['asmenu']).$here;}return $here;}

然后在需要的页面控制器中直接调用此函数

1 0