0

I need to create a megamenu for a site which links to a bunch of category pages.

So I have megamenus for Product Type A & B which are also categories.

Under Product Type A there are headings for Materials, Brand & Usage.

Product Type B will also have a megamenu with a Brand subheading.

At the moment I have a category group for Brands and I'm just listing out all the categories in that group under the respective headings.

So what I need to do is make sure that under the Brand heading for Product Type A that only Brands that have entries that are also assigned to the Product Type A category show, and so on for Type B etc.

For most of the options in these menus I'm just dealing with categories because there won't be any overlap.

But there will for Brands and so I need to look at the entries and then build the list of category options from there.

Any idea how I go about that?

2 Answers 2

1

This is what I ended up doing:

{exp:query sql="SELECT COUNT(entry_id) num_cat_entries
    FROM
    (
            SELECT  entry_id
            FROM    exp_category_posts
            WHERE   cat_id IN (31, 73)
            GROUP   BY entry_id
            HAVING  COUNT(DISTINCT cat_id ) = 2
    ) s"
}
{if num_cat_entries > 0} show the category link {/if}
{/exp:query}
0

What will really make your day is the GWcode Categories add-on. If you set the parameter show_empty="no" you're good to go. Documentation here.

Let us know if we can be of any more help!

EDIT: native EE also has this built in

3
  • You may want to check out the support forums for GWCode at devot-ee.com/add-ons/support/gwcode-categories/viewforum/1444 or contact the developer Leon van Dijk directly.
    – Joan
    May 7, 2014 at 19:53
  • Already using that plugin but it didn't do what I needed which was only show a category if it contained entries that existed in that category AND another category at the same time.
    – Tyssen
    May 7, 2014 at 23:18
  • 1
    GWCode Categories is also REALLY REALLY SLOW when you have large numbers of categories; it uses terribly inefficient queries.
    – adrienne
    May 8, 2014 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.