0

I would like to display all but 1 category in my channel entries loop. I tried doing category="not .." but it doesn't work. Here is my code

{exp:channel:entries channel="lm_edit" sort="desc" category="not 42" limit="5" disable="member_data|trackbacks|playa|pagination" status="open|LMonly" dynamic="no"}
    {if count == "1"}   
    
    {if lm_main_image != ""}
    {exp:ce_img:single src="{lm_main_image}" border="1|b9b3be" width="150" height="75" crop="yes" align="left" class="img-responsive" id="tabimg"}
    {/if}
    {title}
    
    {if lm_deck == ""}{/if}
    {if lm_deck != ""}{exp:eehive_hacksaw chars = "100" append="..."}{lm_deck}{/exp:eehive_hacksaw}{/if}
    
    {if:else}
    
    {title}
    
    {/if}
    {if count == "5"}More News{/if}
   {/exp:channel:entries}

When I get rid of 'not' and just have category="42", all entries from 42 display. When I add back the not nothing is filtered out and all entries display.

0

I had the same issue once and EL said you can't. Per the docs:

Using this parameter will automatically cause ExpressionEngine to ignore any category information specified via the URL. For instance, if you are on a "category page" (e.g. a /C13/ segment in the URL) that will be completely ignored in favor of whatever you have specified via the parameter. 

The EL Supoprt response to acheive it:

But I think you can work around it without it being too clunky. If there’s no category indicator in the url, you want to have the category=“not x”, but if there IS a category indicator, you want it to be purely dynamic- yes?

Note- I would put all of the ‘guts’ of my channel tag in a snippet, so I don’t have to clutter up my template.

Then I’d do a template along the lines of:

{if segment_3 == 'category'} {exp:channel:entries whatever…..} {snip} {/exp:channel:entries} {/if}

{if segment_3 != 'category'} {exp:channel:entries category="not 39" whatever…..} {snip} {/exp:channel:entries} {/if}

Note I used 2 simple conditionals rather than an if/else- because I want them parsed early so that only one of those entry tags is run. That’s for optimization.

| improve this answer | |
  • Thanks Jeremy! This is for the homepage, but for testing purposes the URL for the page looks like website.com/home2/index. So it would never look at segments. – Allison S. May 24 '16 at 16:37

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.