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.

Specifying DIVs for Categories

February 10, 2011 2:56pm

Subscribe [2]
  • #1 / Feb 10, 2011 2:56pm

    Scott Harrington

    85 posts

    Hi, I’m trying to display specific DIVs within a template dependent on what category url is presented in the browser.

    I have tried the following, but it parses an error.

    {if category="C4"}
    {embed="includes/columnwide"}
    {/if}
    
    {if category="C5"}
    {embed="includes/columnwidevocal"}
    {/if}

    The url for the first example being http://www.mysite.co.uk/portfolio/category/C4 and the second url being http://www.mysite.co.uk/portfolio/category/C4

    Any help would be appreciated.

    Thanks

  • #2 / Feb 11, 2011 4:13am

    John Henry Donovan

    12339 posts

    Scott,

    The category id needs to be a whole number to work in your category conditional.

    An easy way around this would be to use the segment conditional

    {if segment_3 == "C4"}
    {embed="includes/columnwide"}
    {/if}
    
    {if segment_3 == "C5"}
    {embed="includes/columnwidevocal"}
    {/if}

    Or in fact if you want to be even smarter about it you could name your embeds columnwideC4 and columnwideC5
    and then just add

    {embed="includes/columnwide{segment_3}"}

    Untested but in theory 😊

  • #3 / Feb 11, 2011 6:50am

    Scott Harrington

    85 posts

    Hi, thanks this works great - just to clear something up for me, how did you determine the segment number? Why 3 and not 1, 2 or 4 or 5?

    Sorry, just so much to learn ;(

  • #4 / Feb 11, 2011 7:42am

    Ingmar

    29245 posts

  • #5 / Feb 11, 2011 8:09am

    Scott Harrington

    85 posts

    Thanks guys

  • #6 / Feb 11, 2011 12:53pm

    Ingmar

    29245 posts

    Glad to see that helped. Please post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases