![](/img/trans.png)
[英]Prestashop: issue with conditional statements in tpl file (PHP, Smarty)
[英]Smarty issue with nested conditional statements
关于smarty和OXID eShop,我有一个小问题。 检索了一堆类别后,我尝试仅显示“排序编号”特殊范围内的类别。 低于100的所有内容均应显示。 但它还会显示> 100的项目。
这是我的代码段:
[{foreach from=$oxcmp_categories item=ocat key=catkey name=root}]
[{if $ocat->getIsVisible() }]
[{if ((int)$ocat->oxcategories__oxsort <100) }]
[{if $smarty.foreach.root.index % 3 == 0}]
<div style="clear: left;"></div>
<div class="mainMenu sub_[{$smarty.foreach.root.index}]">
<div class="mm_header">
<p class="mm_headline">[{$ocat->oxcategories__oxtitle->value}]</p>
</div>
<div>
<img src="[{if $ocat->getThumbUrl() != ''}] [{$ocat->getThumbUrl()}] [{else}] [{'http://placehold.it/299x230'}] [{/if}]" alt="">
<p class="mm_desc">[{$ocat->oxcategories__oxdesc}]</p>
</div>
</div>
[{else}]
<div class="mainMenu sub_[{$smarty.foreach.root.index}]">
<div class="mm_header">
<p class="mm_headline">[{$ocat->oxcategories__oxtitle->value}]</p>
</div>
<div>
<img src="[{if $ocat->getThumbUrl() != ''}] [{$ocat->getThumbUrl()}] [{else}] [{'http://placehold.it/299x230'}] [{/if}]" alt="">
<p class="mm_desc">[{$ocat->oxcategories__oxdesc}]</p>
</div>
</div>
[{/if}]
[{/if}]
[{/if}]
[{/foreach}]
有什么想法可以解决问题吗?
因为我发现您忘了在sortorder调用中写值。 正如我所添加的,您只需要在下面的行中值,它应该可以工作。
[{if ((int)$ocat->oxcategories__oxsort->value <100) }]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.