We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Select entries from *this* category _AND_ *this* _OR_ *this* one...?

Development and Programming

Paul_B's avatar
Paul_B
86 posts
13 years ago
Paul_B's avatar Paul_B

This is a continuation from a post that I mistakenly put in Tech Support

Essentially I’m looking to do this:

{exp:channel:entries channel="events" category="7&(175|177)"}

I realise that the combo logic in the category parameter isn’t standard, and I’ve been trying to write a sql query to achieve the above, but I think I’m doing it wrong as single entries can have multiple category_post entries (as many as the categories they’re assigned to). So I’m not sure if this is achievable with the query module either, or whether I need to beak into php, or what…

Here’s what I’ve written:

<ul>
 {exp:query sql="SELECT 
                 type.cat_id, 
                 type.cat_name as cat_name, 
                 type.cat_url_title,
                 type.group_id,
                 t.title as title,
                 t.status,
                 t.channel_id,
                 t.site_id,
                 d.field_id_32 as date,
                 p.cat_id as cat_id
                FROM 
                 exp_categories type JOIN 
                 exp_category_posts p ON type.cat_id = p.cat_id JOIN
                 exp_channel_titles t ON p.entry_id = t.entry_id JOIN
                 exp_channel_data d ON t.entry_id = d.entry_id
                WHERE 
                 t.status = 'open' AND
                 t.site_id = 1 AND
                 type.group_id = 2 AND
                 /* PROBLEM LINE FOLLOWS! */
                 (p.cat_id = 7 AND ((p.cat_id = 175) OR (p.cat_id = 177))) AND
                 /* PROBLEM LINE ENDS */
                 t.channel_id = 3
                GROUP BY 
                 type.cat_id
                ORDER BY
                    type.cat_order
  LIMIT 5"}
 {if no_results}<li>Sorry, we don't have any events listed</li>{/if}
 <li>{date} {title} {cat_name} {cat_id}</li>
 {/exp:query}
</ul>
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.