首页 > 其他 > 详细

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

时间:2017-09-13 12:57:38      阅读:246      评论:0      收藏:0      [点我收藏+]

以下代码:

<!--{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‘]获取变量;

一般都是从php代码中赋值,但是有时候直接在模版中进行运算处理,类似如上,也是很方便的。

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

原文:http://www.cnblogs.com/feiying100/p/7514251.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!