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.

Questions About Excluding Articles Based On Their Category

July 02, 2007 7:27pm

Subscribe [3]
  • #1 / Jul 02, 2007 7:27pm

    Jason Morehead

    456 posts

    I feel like this is an “EE 101” type of question, but I just want to make sure I understand this.

    Let’s say that I have a site that contains multiple weblogs, with many categories (the same category group is used by all of the weblogs).  For a particular template, I want to exclude all entries that belong to category ID #15.

    So I set up my {exp:weblog:entries} tag like so:

    {exp:weblog:entries weblog="foo|bar" limit="15" category="not 15"}
    
    ...
    
    {/exp:weblog:entries}

    To my mind, this should exclude all entries that have been assigned to category #15—they shouldn’t appear on that particular template at all.

    However, I find that this is not the case.  What I find is that if entries have been assigned to category #15 in addition to other categories, they appear.  The only entries that don’t appear on this template are those that have only been assigned to category #15—they only have one category assignment.

    So my question is this.  How can one exclude articles that have been assigned to a particular category, regardless of whether or not they have been assigned to other categories? To use the example above, how can I exclude all entries in category #15—even if they have multiple category assignments?

  • #2 / Jul 02, 2007 8:07pm

    DSite

    18 posts

    Well, it’s tedious, but the one method which looks like it should work would be something like:

    category="not 15&1|15&2|15&3"

    ... and so on.

    Or maybe there’s a way with conditionals inside the weblog tag?

  • #3 / Jul 03, 2007 10:17pm

    Jason Morehead

    456 posts

    Alas, that didn’t work either.

    I think the way that I’m going to have to do it is via conditionals within the {exp:weblog:entries} tag, and use CSS to hide the entries that meet the necessary criteria.  It’s not optimal, but I guess it’ll have to work for now.

  • #4 / Jul 03, 2007 10:46pm

    DSite

    18 posts

    Bummer. 

    I guess what you describe would work, although the entries would still show up in the source code. 

    Maybe a custom status for all articles with category 15?  It’s an extra step to remember when publishing, but you could definitely grab that as a parameter to exclude those articles.

    I suppose there’s probably a way around it with a query, but it seems like every time I try a query these days, it makes my head spin and I end up crawling to Derek for help.  Would something like this be a start?

    Now that I look back, I guess the docs don’t show an example where you can use “not”, “|” and “&” all at the same time.  It seems to be a logical extension of the current parameter possibilities, though, so I could see this being a good feature request.

  • #5 / Jul 03, 2007 11:35pm

    Jason Morehead

    456 posts

    I’ve thought about using a custom query—thought I prefer not to if I don’t have to.  I might revisit the custom query idea once I’ve got some other issues with the site in question hammered out.

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

ExpressionEngine News!

#eecms, #events, #releases