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 Conditional Help

June 27, 2012 3:22pm

Subscribe [3]
  • #1 / Jun 27, 2012 3:22pm

    Stephen O'Connor

    24 posts

    Hi,

    I have two categories - website-design and graphic-design - within one category group - work - and I am trying to link to a different view page depending on what category that entry is assigned to, so if I had 1 entry that was assigned to the category website-design I would like that entry to link to the view template for my website design work, the same if it were assigned to grpahic-design for it to link to my view template for graphic design, but I can’t seem to get it work, all the entries link to the same view template.

    Here’s what I have at the moment:

    {exp:channel:entries channel="work" limit="3" disable="category_fields|member_data|pagination" status="homepage-featured"}
         <div class="feature">
              <ul class="img_list">
                    <li class="image_one">{if category_id == "1"}<a href="http://{title_permalink=work/website-design/}">{if:else}<a href="{title_permalink='work/graphic-design/'}">{/if}<span class="rollover"></span>{project_image_small}</a></li>
              </ul>                    
              <h5>{company}</h5>
    <p>          {what_i_did}<br />
         </div><!-- END FEATURE --> <br />
    {/exp:channel:entries}

    Any help would be appreciated and stop me from pulling my hair out!

  • #2 / Jun 27, 2012 5:58pm

    DanL

    56 posts

    I think you need to wrap your IF in {categories} tags:

    {categories}
     {if category_id == "1"}
      <a href="{title_permalink='work/website-design/'}">
     {if:else}
      <a href="{title_permalink='work/graphic-design/'}">
     {/if}
    {/categories}

    Pretty sure you can’t just use category_id on it’s own like that…

  • #3 / Jun 28, 2012 4:21am

    Stephen O'Connor

    24 posts

    Wonderful!! 😊

    That worked, thanx.

  • #4 / Jun 28, 2012 12:07pm

    Shane Eckert

    7174 posts

    Hey Stephen,

    I am glad that Dan was able to help you out! Thanks Dan!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases