field("catid,catname,asmenu")->where("catid=$catid")" />
牛骨文教育服务平台(让学习变的简单)
博文笔记

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

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

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


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


然后在需要的页面控制器中直接调用此函数
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。