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.

Including one category and excluding another

December 01, 2011 2:38pm

Subscribe [2]
  • #1 / Dec 01, 2011 2:38pm

    tcast

    4 posts

    I’ve got some entries that are categorized like so:

    Entry ID: #1865
    Categories: #10, #17.

    Entry ID: #1865
    Categories: #10

    I need to write an entries tag to get the first entry that has category id #10, and exclude id #17.

    Intutively, the tag should be something like this:

    {exp:channel:entries limit="1" category="10 not 17"}

    or

    {exp:channel:entries limit="1" category="10&!17"}

    I can’t use a conditional in the loop, because it has to be limited to one entry, and I can’t predict how far I’d have to loop through to find a matching entry, and I can’t break out of a loop when I find it anyways. It’s either a tag param I’m using wrong or missing, or I’ll have to pull it all out and write it as a php function in a module, which I reallllly don’t want to have to do in this instance, because this should be such a simple operation.

  • #2 / Dec 02, 2011 3:19pm

    Kevin Smith

    4784 posts

    Hi tcast,

    I see what you’re trying to accomplish, but you’re suspicions are right: there’s not a native way to do that. The only thing I can think of to accomplish this natively is to negate all the categories you don’t want to appear and use the uncategorized_entries parameter to exclude entries that aren’t yet categorized. It’s not elegant, but it should work.

    Hope this helps!

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

ExpressionEngine News!

#eecms, #events, #releases