thinkphp how to get the current position of columns and articles, _php tutorial

Source: Internet
Author: User

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. true 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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.