开发者

Expression Engine - if category_id not working?

I can't seem to get the if conditional statements for category id to work on a view (title_permalink) page.

My code is as follows:

{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|开发者_JS百科10|11"}<b>Price (GBP):</b>{/if}{/categories} {product_price}</p>
{/exp:channel:entries}

Surely this should work? So if i'm on category id 8 it will display "Price (USD)" and if i'm on category id 2 it should display "Price (USD)"?


Your syntax is incorrect. EE conditionals follow PHP's conditional syntax very closely.

Try this:

{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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜