Smarty How do I nest loops? This paper mainly introduces the section nested loop usage of smarty, and analyzes the implementation technique of nested loop operation using section in the form of simple example, and the friends who need can refer to the smarty. We hope to help you.
Specific as follows:
{section name= "SEC1" loop= $typeList}<table class=left20 height=25 cellspacing=0 cellpadding=0 width=624 background= Images/indexbg.gif border=0> <TBODY> <TR> <td class=zi align=left width=554 height=25> <FO NT color= #ffffff ><b>{$typeList [sec1].typename}</b></font></td> <td vAlign=top width= href= "hot.html" ><a" height= "border=0></a>" </TD> </TR></TBODY></TABLE> <table cellspacing= "0" cellpadding= "0" > <tr> {sectio n name= "sec2" loop= $typeList [Sec1].shop} <td><table cellspacing= "0" cellpadding= "0" > <tr> <TD valign= "center" align= "Middle" width= "$" ><table cellspacing= "0" cellpadding= "0" > <tr> <td><a href= "show_prop.php?id={$typeList [Sec1].shop[sec2].id}" target= "_blank" ></a></td> </tr> </table></td> </tr> <tr> <td class= "Hongzi" align= "middle" > <a href= "a01.htm" >{$typeList [SEC1]. Shop[sec2].name} </a> </td> </tr> <tr> <td class= "Zi2" align= "middle" > Quantity: {$t Ypelist[sec1].shop[sec2].num} </td> </tr> <tr> <td class= "Zi2" align= "Middle" > Price : {$typeList [Sec1].shop[sec2].price} white gold </td> </tr> </table></td>{/section} </tr> </table>{/section}
SEC1 's $typeList [sec1].shop as a sec2 loop
You can fetch the contents of the array in the shop.
Related recommendations:
How smarty templates use variable conditioners
Smarty How to generate simple form elements
An explanation of how the Smarty template engine caches