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.

Filter weblog by two categories: entries with apples AND orange selected (not apples|oranges)

October 29, 2007 7:16pm

Subscribe [2]
  • #1 / Oct 29, 2007 7:16pm

    Rob Quigley

    236 posts

    I would like to show all entries that have two categories selected = apples and oranges rather than apples or oranges. Is this possible to do - anyone know any snappy php code to accomplish with a query or some such goodyness?

  • #2 / Oct 29, 2007 7:18pm

    Derek Jones

    7561 posts

    Try an inclusive stack, Rob, e.g.:

    category=“4&5”

  • #3 / Oct 29, 2007 7:24pm

    Rob Quigley

    236 posts

    Thanks Derek!! I overlooked that in the docs. That Should do it. 😊

  • #4 / Oct 30, 2007 2:48pm

    Rob Quigley

    236 posts

    I have one instance where ideally I’d like to filter any content by one constant category (Apples) AND several other categories - but don’t want all categories to be stackable:

    Want: Apples AND Oranges OR Apples AND Bananas OR Apples AND Cherries

    Don’t want: Apples AND Oranges AND Bananas AND Cherries

    Any ideas?

  • #5 / Oct 30, 2007 2:51pm

    Derek Jones

    7561 posts

    That’s a bit more complex and can’t be handled by parameters unfortunately.  One way that comes to mind is a PHP database query on input to get the entry ids from the exp_category_posts that fit your criteria could be used to generate a list of entry id’s to use in the weblog entries tag’s entry_id= parameter.

  • #6 / Oct 30, 2007 2:57pm

    Rob Quigley

    236 posts

    Thanks for the heads-up! I think we’ll just restructure our content to fit into two categories instead of three.

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

ExpressionEngine News!

#eecms, #events, #releases