Calculate ThinkPHP cyclically nested to print out the list of parent classes and child classes. how can this problem be solved?

Source: Internet
Author: User
Find ThinkPHP in 40 minutes and print out the parent class and subclass list & nbsp; hello everyone, I have been learning the thinkPHP framework recently, I want to print out a data list cyclically on the template page. the format is: first, the parent class name, then the corresponding subclass list, and then the other parent class name, print the corresponding subclass of the parent class, and so on... I use table layout. the format is as follows: & nbsp; & 40: ThinkPHP loop nesting to print out the list of parent and child classes.

Hello everyone, I have been studying the thinkPHP framework recently. I want to print out a data list cyclically on the template page. the format is: first, the parent category name, then print out the corresponding subclass list, then print another parent class name, then print the corresponding subclass of the parent class, and so on... I use table layout. the format is as follows:


Category name overview

Parent class name 1......
Subclass name 1 .....
Subclass name 2 .....
Subclass name 3 .....
Parent class name 2......
Subclass name 1 .....
Subclass name 2 .....
Subclass name 3 .....


Could you tell me how to implement it with volist, or is there any better way? thank you !!


------ Solution --------------------
Don't you read his manual?

Volist tag
The Volist tag is mainly used to output a dataset or multi-dimensional array cyclically in the template.

Generally, the results returned by the select and findall methods of the model are a two-dimensional array, which can be directly output using the volist label.

In Action, first assign values to the template:

$ User = M ('user ');

$ List = $ User-> select ();

$ This-> assign ('list', $ list );



The template definition is as follows:



{$ Vo. id}

{$ Vo. name}



The name attribute of the Volist tag indicates the variable name assigned to the template. Therefore, it cannot be changed in the template file at will. Id indicates the current cyclic variable, which can be specified at will, but must not conflict with the name attribute. for example:



{$ Data. id}

{$ Data. name}



Some data can be output, for example, 5th ~ 15 records



{$ Vo. name}




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.