1

I'm trying to display some information based on the category an entry is in, however I can't get my head around it… If the entry is in more than 1 category it'll still show the information, how do I make it work so if category_id is selected at all it'll not show the information? Here's my current code:

{exp:channel:entries channel="courses" category="2"}
  {categories show_group="2"}
    {if category_id != "2"}
       {course_start-date format='%d %M %Y'}
    {/if}
 {/categories}
{/exp:channel:entries}
3
  1. php (PHP Parsing Stage: ouput)

    {exp:channel:entries channel="courses" category="2"}

    <?php $excludefrom = '|{categories}{category_id}|{/categories}'; ?> 
    <?php if (substr_count($excludefrom, "|2|") == 0){?> 
          {course_start-date format='%d %M %Y'}
    <?php } ?> 
    

    {/exp:channel:entries}

    (you can do the same using Switchee the same way with regex)

update

Additional solution:

{exp:channel:entries channel="courses" category="2"}

   {if "{categories show_group="2"}2{/categories}" != "2"}
      {course_start-date format='%d %M %Y'}
   {/if}

{/exp:channel:entries}
2
  • Thanks Max, explains why I haven't been able to get it to work. Is there definetly no way I can achieve this by using ExpressionEngine's tags alone?
    – Nick
    Nov 5 '13 at 9:11
  • 1
    I just updated my post - possible second solution will be good for you.
    – Max Lazar
    Nov 5 '13 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.