{foreach name=goods_list from= $best _goods Item=goods} How to understand?

Source: Internet
Author: User
Keywords Php smarty WeChat public platform
Tags smarty template
Index.dwt
Recomment_best.lbi

      
  
                                     又是什么意思??     这样的写法,属于什么语法??是 smarty ?      求解决??谢谢          

Reply content:

Index.dwt
Recomment_best.lbi

      
  
                                     又是什么意思??     这样的写法,属于什么语法??是 smarty ?      求解决??谢谢          

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

  • Related Article

    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.