From is the value of your backstage assign, for example, in the action of your controller inside the backstage $smarty->assign (' Best_goods ', $best _goods); Spicy, the value you receive from the template file must be $best_goods {foreach name=goods_list from= $best _goods Item=goods} Next, you can use the $goods variable in the template, by using {$goods}, $goods is now an array, you can go through the. Operation, like this {$goods. URL}, or accessed by an array, like this {$goods [' url ']}, The Name property does not seem to be necessary, you try
This is the Foreach loop syntax for the smarty2.0 template engine, which will eventually be compiled into PHP code by the template engine and executed!
First look at the Official document description:
Name:smarty template engine, the name of the Foreach object itself, to facilitate subsequent operations, such as serial number judgment, etc.
{if $smarty.foreach.goods_list.index % 5 == 0} Title {/if}
From: In your case, it's the equivalent of a product list array. Item: In your case, it's the equivalent of a product.
{foreach name=goods_list from= $best _goods Item=goods} $best _list is an array, which means that the loop will best_list the elements of this array to goods to use
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.