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.

Multiple category id's

April 03, 2011 5:51pm

Subscribe [2]
  • #1 / Apr 03, 2011 5:51pm

    mechwd

    33 posts

    I have a portfolio that has different categories, and some of those portfolio items have multiple categories.  I am having trouble getting it to export classes based on what categories it has.  If a portfolio has one category assigned to it, it works fine. If it has two or more, it breaks and doesn’t do anything.

    Here is my code:

    {exp:channel:entries channel="portfolio" orderby="title" sort="asc" category_group="1" disable="member_data"}
                
            <li class="all{if {categories}{category_id}{/categories} == '6'} branding{/if}{if {categories}{category_id}{/categories} == '1'} print{/if}{if {categories}{category_id}{/categories} == '2'} web{/if}" data-id="id-{entry_id}">
                <div class="portfolio_item">
                    <a href="http://{url_title_path=portfolio/detail}">_                    {thumb}_                    <h4>{title}</h4><p>_                </a><br />
                </div><br />
                <div class="portfolio_shadow"></div><br />
            </li><br />
            <br />
            {/exp:channel:entries}

  • #2 / Apr 04, 2011 4:00pm

    Brandon Jones

    5500 posts

    Hi mechwd,

    The structure of your conditionals looks a bit off. Try something like this (line breaks added for clarity):

    {categories}
       {if category_id =='6'} branding{/if}
       {if category_id =='1'} print{/if}
       {if category_id =='2'} web{/if}
    {/categories}

    Does that help?

  • #3 / Apr 04, 2011 7:24pm

    mechwd

    33 posts

    I will try it when I get back to my production computer

  • #4 / Apr 05, 2011 10:59am

    mechwd

    33 posts

    I believed it worked. Thank you very much.

  • #5 / Apr 05, 2011 9:38pm

    Lisa Wess

    20502 posts

    Happy to see Brandon was able to help you!  if anything else comes up, please do start a new thread.  Thank you!

  • #6 / Apr 05, 2011 9:39pm

    Lisa Wess

    20502 posts

    and really resolving. =)

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

ExpressionEngine News!

#eecms, #events, #releases