0
我有一個關於smarty和OXID eShop的小問題。在檢索一組類別之後,我嘗試僅顯示「排序號碼」特殊範圍內的類別。應顯示低於100的所有值。但是,這也顯示了項目> 100Smarty問題嵌套條件語句
這裏是我的代碼片段:
[{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}]
任何想法,問題出在哪裏可以?
爲什麼使用模板引擎來執行邏輯操作?如果您只想顯示100個類別,則只應從控制器/模型向視圖發送100個類別。 – skrilled 2014-09-26 19:45:45
它可能與你在第二個if語句中對'int'的轉換有關。也許這個演員陣容正在做你不想做的事情,因爲如果你必須先演員,那麼顯然這是另一回事。當你將它轉換爲int類型時,你可以試着查看'$ ocat-> oxcategories__oxsort'的值。但是,我會建議您遵循skrilled的提示,並且只將您需要的數據發送到表單。 – Bono 2014-09-26 21:33:53