ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Category {if} statement?

October 30, 2008 7:00pm

Subscribe [1]
  • #1 / Oct 30, 2008 7:00pm

    DarkGrave

    3 posts

    Yes, I searched and found something similar actually dead on with what I was trying to do. But, it lead to no answers! I need all posts, but I want to change some templating code for different categories.

    Heres my general idea:

    {exp:weblog:entries weblog="posts" orderby="date" sort="desc" limit="15" disable="member_data|trackbacks"}
    {if category_id == "1"}
    In cat one
    {if:elseif category_id == "2" }
    In cat two
    {/if}
    {/exp}

    For some reason it doesn’t produce a weird error when it has two equal signs. When there is one it produces an ugly ugly error about eval. However, even with the error gone. THIS IS NOT WORKING. Nothing shows up.


    I figured it out. To save people some trouble. The only thing is that you can’t use HUGE blocks of code within it.

    {exp:weblog:entries weblog="posts" orderby="date" sort="desc" limit="15" disable="member_data|trackbacks"}
    {categories}
    {if category_id == "1"}one{/if}
    {if category_id == "2"}two{/if}
    {if category_id == "3"}three{/if}
    {if category_id == "4"}four{/if}
    {if category_id == "2"}five{/if}
    {/categories}
    {/exp}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases