Thinkphp calls the second-level column (second-level classification) Function + complete template code

Source: Internet
Author: User
Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn thinkphp calls the second-level column (second-level classification) Function + template + controller complete code.
Many may develop their own cms and other programs in the thinkphp framework,
I have raised a lot of questions about Level 2 categories and level 2 columns, because I am also looking for this question,
So I will send the complete message today. Don't ask me who I am. My name is xiaozeng. You can add my QQ839024615.

First, you have to have a data table that must have the id field parent id field (parent field, that is, who is his father)
Table Structure:

Id is his sid is his parent id, that is, who is his father at the parent level (px I set to sort, this is not in this topic)

Sid description 0 indicates that he has no father.

Controller code // Obtain the top-level category Controller
Public function index (){
$ Data = M ('type ');
$ Where ['sid '] = 0; // obtain the ancestor first
$ List = $ Data-> where ($ where)-> order ('px ')-> select ();
$ This-> assign ('LIST', $ list );
$ This-> display ();
}
Function call second-level calls. Of course, some of his sons can also be called. Here I will talk about second-level calls.
Put the function code in/project/Common. php for your own configuration. // Obtain the subcategory
Function SidType ($ sid ){
$ Data = M ('type ');
$ Where ['sid '] = $ sid;
$ List = $ Data-> where ($ where)-> order ('px ')-> select ();
Return $ list;
}
Template code
























ID Sort Name Operation
{$ Vo. id} Other {$ vo. name} Preview content modification and Deletion
{$ Vo. id} Pipeline pipeline {$ vo. name} Preview content modification and Deletion
The above is my own. If you don't need it, you can just remove it. You just need to understand what it means. Don't worry about what others represent, as shown in the final result.


The following is short for the lower-level // Top-level

// Level 2

// Level 3

//... Never get it.


The following is a 7-level query. If there are no subordinates, the query will be interrupted later.

I am Zeng, QQ839024615, and I want to talk more ,,,

AD: truly free, domain name + VM + enterprise mailbox = 0 RMB

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: info-contact@alibabacloud.com 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.