field("catid,catname,asmenu")->where("catid=$catid")" />
入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

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

创建时间:2015-12-16 投稿人: 浏览次数:1174

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


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;
}


然后在需要的页面控制器中直接调用此函数
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。