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.

problem with category_group

November 26, 2012 5:44am

Subscribe [4]
  • #1 / Nov 26, 2012 5:44am

    Muhammad

    26 posts

    Hello
    a channel has two category group (id:1,7)
    an entry could be in one of these categories or both or no one
    I want to show all entries that is not in category 7

    when i say

    {exp:channel:entries channel="selsela" status="open" category_group="not 7" limit="10" paginate="bottom" }

    all entries that has in category 1 and 7 appears
    than i want to solve
    thanks

  • #2 / Nov 26, 2012 6:40am

    John St-Amand

    865 posts

    Yeah it’s likely leaving out anything that is in category group 7 alone, but entries assigned to category group 1 AND 7 are still showing up, is that right?

  • #3 / Nov 26, 2012 6:45am

    Muhammad

    26 posts

    Yeah it’s likely leaving out anything that is in category group 7 alone, but entries assigned to category group 1 AND 7 are still showing up, is that right?

    yes that exactly what happen and I want to prevent any entry assigned to category group 7 even its in cat_group 1 either

  • #4 / Dec 02, 2012 3:52am

    Muhammad

    26 posts

    hello
    any help

  • #5 / Dec 02, 2012 6:48am

    Wouter Vervloet

    758 posts

    Hi Muhammad,

    Looking at the source of the channel module I don’t think you can do anything about this (natively)... it’s just the way MySQL works when running a query like this.

    I’m trying to come up with a way to solve this, but I’m drawing a blank right now…

    – Wouter

  • #6 / Dec 02, 2012 9:30am

    MadWebDesigns

    147 posts

    Hi Muhammad,

    I’ve never tried this so not sure if it will work but what if you do something like this:

    {exp:channel:entries channel="selsela" status="open" category_group="not 7|7&1" limit="10" paginate="bottom" }

    The idea here is we don’t want any entries that have the category group 7 and category group that has 7 and 1 at the same time. It’s not perfect but it might do the trick for you. I hope it helps.

    Cheers,

    Mike

  • #7 / Dec 02, 2012 9:39am

    Muhammad

    26 posts

    thanks MadWebDesigns and wouter
    i have tried “not 7 | 7&1” but it seems that category_group not take ‘&’
    now I am trying in query it works but I want to return alot of fields that are related to alot of tables due to complex database structure of ee

  • #8 / Dec 03, 2012 9:45am

    Muhammad

    26 posts

    Solved by complex query

    {exp:query sql="SELECT distinct entry_id FROM exp_channel_titles b, (select entry_id as aid from exp_category_posts WHERE cat_id in (select cat_id from exp_categories where group_id != 7)) a WHERE a.aid = b.entry_id and b.channel_id = '16' and b.status = 'open' order by entry_date DESC"}

     

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

ExpressionEngine News!

#eecms, #events, #releases