ecshop模版循环遍历中自动调用函数

如下代码:php

<!--{foreach from=get_categories_tree(0) item=cat name=cat0}-->

                  <!--{foreach from=get_brands1($GLOBALS['smarty']->_var['cat']['id']) item=bchilder name=bchilder}--> 
                  {if $smarty.foreach.bchilder.iteration < 9} <a href="{$bchilder.url}" class="img-link" target="_blank" title="{$bchilder.brand_name|escape:html}"> <img src="data/brandlogo/{$bchilder.brand_logo}" width="90" height="36" /> </a> {/if} 
                  <!--{/foreach}--> 

<!--{/foreach}-->

 

俩个foreach循环中,from中嵌套了方法,方法中使用$GLOBALS['smarty']->_var['cat']['id']获取变量;html

通常都是从php代码中赋值,可是有时候直接在模版中进行运算处理,相似如上,也是很方便的。url

相关文章
相关标签/搜索