Thinkphp get the column and the current position of the article method,
In this paper, we describe the methods of thinkphp getting the column and the current position of the article. Share to everyone for your reference. The implementation method is as follows:
Today, some of the details of the blog to improve, which modified the column page and the article page of the "Current location." Before the column is very few, the dead way to do (the name of the column), now more columns, gradually two columns, three columns also came, this way is obviously not suitable, so it improved a bit. It is not difficult to use a recursive function to do it.
The test results are as follows:
View the source file effects: Copy the Code code as follows: Home--PHP learning--ecshop-ecshop two times development, Ecshop add Baidu Map, support peripheral Markers
The copy Code code is as follows://Current Position-the first parameter CATID is the ID of the current column, the second parameter is the title of the article, the second parameter is empty when calling the current position of the column.
$this->assign ("Now_here", $this->now_here ($catid, $res [' title ']);
Explain, the column table category in the CATID column id,catname for the column name, Asmenu as the column parent ID, when the top column, Asmenu for 0.
protected function Now_here ($catid, $ext = ") {
$cat = M ("Category");
$here = ' home ';
$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;
}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/902780.html www.bkjia.com true http://www.bkjia.com/PHPjc/902780.html techarticle thinkphp the method of obtaining the current position of the column and the article, this paper describes the method of thinkphp getting the column and the current position of the article. Share to everyone for your reference. Concrete implementation methods such as ...