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.

Is there any way to show Entries assigned to single (not multiple) categories?

July 11, 2011 6:24pm

Subscribe [4]
  • #1 / Jul 11, 2011 6:24pm

    Ryon

    6 posts

    The regular Channel Entries Tag Parameters seem to allow you to:

    Show entries assigned to CategoryA (even if it is in also in CategoryB) :  category=“A”

    Show entries assigned to CategoryA or CategoryB :  category=“A|B”

    Show entries assigned to both CategoryA and CategoryB :  category=“A&B”

    Show entries Not assigned to CategoryA and CategoryB :  category=“not A&B”

    Show entries assigned to neither CategoryA and CategoryB :  category=“not A|B”

    Is there a way to show entries assigned to CategoryA but not also assigned to CategoryB?
    something like category=“A, not B”

    I tried doing   category=“not B|C|D|E”    in exp:channel:entries tag, but it didn’t seem to have any effect.

    I think this could be done using conditionals inside the exp:channel:entries, but I wanted to avoid that as I think it would cause considerable more page-load overhead and force me to use more templates (less DRY)

    I surveyed a lot of Category plugins, too and nobody seems to mention this use case

    Any suggestions?

    Thanks

  • #2 / Jul 12, 2011 3:43pm

    Kevin Smith

    4784 posts

    Hi Ryon,

    For the category tag parameter, you should be using the category ID rather than the name of the category. So it should take the forms shown in the documentation examples. That may be why your exclusion wasn’t working.

    I don’t know if it will work, but try

    category="1 not 2"

    If that doesn’t work, you’ll need to use the exclusion you tried in combination with uncategorized_entries:

    category="not 2|3|4|5" uncategorized_entries="no"

    Does that help?

  • #3 / Jul 29, 2011 5:40pm

    Ryon

    6 posts

    Thank you for the reply.
    I was using category ID’s, just used the A/B thing as pseudo-code.

    category="1 not 2"

    Doesn’t have any effect (“not” part ignored).

     

    category="not 2|3|4|5" uncategorized_entries="no"

    Seems to be functionally equivalent to:

    category="1"

    Which shows entries that are assigned to 1 and 2, 3, etc.


    Does anyone have any other ideas on how to isolate a single category when entries have been assigned to multiple categories?

  • #4 / Jul 30, 2011 8:27pm

    Ryon

    6 posts

    I was able to get closer to a working solution using BW Category Count add-on

    {exp:channel:entries channel="x" category="3" }
    
    {if {category_count show_group='2'} == 1}
    [code]
    {/if}
    
    {/exp:channel:entries}

    This will filter out any entries that have 2+ categories (from specified category group) assigned.

  • #5 / Aug 01, 2011 7:20am

    Sue Crocker

    26054 posts

    Hi, Ryon. Looks like you have a solution, will that work for you?

  • #6 / Nov 16, 2011 9:51am

    Kevin Smith

    4784 posts

    To anyone following this thread for updates on the bug report here, a solution has been posted!

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

ExpressionEngine News!

#eecms, #events, #releases