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