2011-07-07 21 views
1

我似乎無法得到如果條件語句的類別ID工作在視圖(title_permalink)頁面上。表達式引擎 - 如果category_id不起作用?

我的代碼如下:

{exp:channel:entries channel="product"} 
    <p><b>Product:</b> {product_item} &ndash; {categories}{if category_id == "8|9|10|11"}<b>Price (USD):</b>{/if}{if category_id == "not 8|9|10|11"}<b>Price (GBP):</b>{/if}{/categories} {product_price}</p> 
{/exp:channel:entries} 

當然這應該工作?所以,如果我在類別ID 8,它會顯示「價格(美元)」,如果我在類別ID 2,它應該顯示「價格(美元)」?

回答

2

您的語法不正確。 EE條件非常接近PHP的條件語法。

試試這個:

{exp:channel:entries channel="product"} 
    <p><b>Product:</b> {product_item} &ndash; {categories} 
     {if category_id == "8" OR category_id == "9" OR category_id == "10" OR category_id == "11"}<b>Price (USD):</b>{if:else}<b>Price (GBP):</b>{/if} 
    {/categories} {product_price}</p> 
{/exp:channel:entries} 
+0

嗨d-搖滾,感謝,但它扔我回一個錯誤:解析錯誤:語法錯誤,意想不到的T_ELSE在/ home /的public_html /管理/ expressionengine /庫/功能。 php(650):線上的eval()'d代碼77 – jay24888

+0

沒關係,對不起,我打開了一個標籤!作品一種享受。謝謝!那麼是否沒有像{if category_id ==「1 | 2 | 3 | 4」}這樣的條件? – jay24888

+0

正確 - EE中的條件(基本上)直接轉換爲PHP條件,所以PHP條件的所有語法和規則都適用。 –