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}