1

I have a channel called foo.

Some entries in the foo channel have been assigned categories, some are not.

I wanted to group the entries based on their categories.

Since some of them don't have categories, I want to be able to specifically search for them.

Is there a way to do it?

{exp:channel:entries
    channel="foo"
    disable="member_data|pagination"
    dynamic="no"
    orderby="entry_id"
    sort="asc"
    category="" /* HOW TO FILTER FOR "NO CATEGORIES"? */
}
2

Use the "NOT" feature in Categories and list all of your other Categories.

category="not 4|5|7"

Simply list all of your categories with the "NOT" declaration and it should show everything else.

You could also group multiple categories inside your channel with an if statement for each category.

{if category_id == ""} this should target empty categories {/if}
3
  • Thanks for the response Mike. I am just curious. Is there a way to get uncategorized entries without knowing the categories beforehand(which your solution assumes)? Sep 30 '13 at 2:19
  • 1
    Ah the second solution would work then in that case. Sep 30 '13 at 2:19
  • :) - sorry i forgot to add that on my original post, and just edited it. Sep 30 '13 at 2:48
4

If you want a more dynamic solution, this works too:

category="not |"

I'm not 100% sure why it works but it appears to be because the "not" operator returns entries without a category. The EE help docs mention this:

[http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#category][1]:

NOTE: When you use the category="3|4" parameter (not excluding), you are implicitly telling ExpressionEngine to only deal with entries that have been assigned one or more categories. If you have entries that haven’t been categorized then they will be ignored and not included in the results. However, if you are using exclusion (category="not 3|4"), then you will be shown all entries without those categories including those without any categories assigned. To change this behavior when excluding categories use the uncategorized_entries parameter.

Since the above parameter doesn't match any actual categories the result is a list of entries that doesn't have an assigned category.

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.