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.

This required category and one of these other categories

April 26, 2013 10:27am

Subscribe [2]
  • #1 / Apr 26, 2013 10:27am

    Justin Koivisto

    3 posts

    What I want to do seems fairly simple in thought, but I am not sure how to put it in effect. I want to pull up to 5 entries from a channel based on categories selected. Sure no problem:

    {exp:channel:entries channel="articles" category="9|10" dynamic="no" limit="5"}

    but now I want to require that there is another category as well. That is, I want to pull entries that are in either 9 or 10, but MUST be in category 4 (from a different category group) as well.

    of course, my first thoughts included trying:

    category="4&9|10"
    category="4&(9|10)"

    neither of which worked.

    Anyone have some suggestions on how to pull the entries? I am probably overlooking something simple, but I may just be too close to the project to see it.

  • #2 / Apr 29, 2013 5:59am

    mixing AND and OR filters is not working in EE. You’ll need to use the Query-Module and maybe a bit of php.

    OR 😉

    My solution was to embed a template and use a embed variable for the categories:

    {embed='template_group/.article' 
      category='9&4'
    }
    
    {embed='template_group/.article' 
      category='10&4'
    }

    Solspace said, that they are implementing that functionality in their upcoming Super Search Update (2.1):
    http://www.solspace.com/forums/viewthread/15386/#60093

    But I still hope that EE will support that functionality some day…

     

  • #3 / Apr 29, 2013 9:48am

    Justin Koivisto

    3 posts

    Thanks for the reply!

    I was thinking that was the case when I realized it was likely using bitwise operators. I ended up using the query module with the following to get the entry IDs I wanted:

    SELECT entry_id FROM exp_category_posts WHERE cat_id = 4 AND entry_id IN (SELECT entry_id FROM exp_category_posts WHERE cat_id = 9 OR cat_id = 10)

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

ExpressionEngine News!

#eecms, #events, #releases