0

I am designing an EE site for a board game cafe which sells games online and also has a games library in-store for playing. The client wants to enter the game information only once into the shop database (games will be for sale online only, available in store only, or both). Initially, when I did the online shop coding for online sales (I'm using Expresso Store), I used the categories as navigation. I did this so that the client can easily add categories. The client wants the same categories available for the in-store games library, so I copied the entire Store template group for the games library and modified the product template to remove the pricing and ‘add to cart’ functionality, but I need different sidebar category navigation in this template group as not all games available online for sale are available in store. I made a new category group called ‘games library’ and was hoping that only products with that checked (id 10) will return the other categories.

I have sidebar navigation which looks (in part) like this:

<h2>Genres</h2>
{exp:gwcode_categories group_id="4" show_empty="no"}
     <a href="{path=games_library/cat/{cat_url_title}}">{cat_name}</a>
{/exp:gwcode_categories}

<h2>Age Groups</h2>
{exp:gwcode_categories group_id="8" show_empty="no"}
     <a href="{path=games_library/cat/{cat_url_title}}">{cat_name}</a>
{/exp:gwcode_categories}

I only want items to show up in this navigation if another category (ID 10) is also checked.

I tried this, but it doesn’t work – it just shows empty bullets

<h2>Genres</h2>
{exp:gwcode_categories group_id="4" show_empty="no"}
{if cat_group_id == '10' AND cat_group_id == '4'}
     <a href="{path=games_library/cat/{cat_url_title}}">{cat_name}</a>
{/if}
{/exp:gwcode_categories}

Can anyone help?

5
  • You say you "made a new category called 'games library'" but is this a category or a category group? The others seem to be different category groups. Can you list which category groups you have?
    – Ian Young
    Apr 21, 2013 at 16:01
  • It's a category group. I have the following: ID2 = Designer (108 sub categories) ID8 = Game Age (11 sub categories) ID10 = Games Library ID4 = Genres (13 sub categories) ID6 = Number of Players(17 sub categories) ID7 = Playing Time (13 sub categories) ID5 = Publisher (22 sub categories) ID3 = Quick Picks (7 sub categories) Is this helpful? Apr 21, 2013 at 17:19
  • If I understand correctly, what you're really looking for is to output a list of categories that are used in a particular subset of product entries (those which have a single particular category selected). What is the category_id of the category in your games_library group? (Not the group_id)... Your conditional can never work, since a category can only ever belong to one group. Apr 21, 2013 at 23:47
  • The cat group id is 241. I tried <h2>Genres</h2> {exp:gwcode_categories group_id="4" show_empty="no"} {if cat_group_id == '241' AND group_id == '4'} <a href="{path=games_library/cat/{cat_url_title}}">{cat_name}</a> {/if} {/exp:gwcode_categories} But that didn't work either. Still returning blank bullets. Apr 22, 2013 at 7:41
  • This is getting pretty hard to follow. :) OK, so I'm a little confused as to what both cat_group_id == 241 and group_id == '4' are? I'm not sure they can be interchanged like that. As James mentioned categories can only belong to one group so can you confirm we're only pulling from one group? If so what group (name and ID) is this?
    – Ian Young
    Apr 22, 2013 at 17:50

2 Answers 2

0

You could perhaps feed a list of entry ids to the gwcode plugin's entry_id parameter via Stash like this:

{exp:stash:set name="the_ids" trim="yes" parse_tags="yes"}
  {exp:channel:entries category="241" limit="999" channel="products" disable="categories|pagination|custom_fields|member_data"}
    {entry_id}|
  {/exp:channel:entries}
{/exp:stash:set}

{exp:gwcode_categories parse="inward" entry_id="{exp:stash:get name='the_ids'}" show_empty="no" style="linear"} 
   {if group_start}
     <h2>{cat_group_name}</h2>
     <ul>
   {/if}

    <li><a href="{path=games_library/cat/{cat_url_title}}">{cat_name}</a></li>

    {if group_end}
      </ul>
    {/if}
{/exp:gwcode_categories}
3
  • James, thanks so much for trying, but that didn't work either. I don't know about Stash (which I did install, btw), but with the code you sent, is it only returning data for category 241? It actually has to return for the other Category Group IF 241 is checked. So it needs to return the genre data (group id 4) for all products which also have category 241 ticked (are part of the games library). Apr 22, 2013 at 13:06
  • Yep, it should do that ok. The problem might be down to parse order. Try hardcoding a small list of entry ids instead of using stash:get to see if that works, then we can fix the parse order, or just resort to an embed. In order to get at all the right categories, you need to define the subset of entries from which to pull them, which is what the first chunk of code does (simply a pipe-separated list of all entries categorised under 241). Then the second chunk should grab all the other categories. Apr 22, 2013 at 14:11
  • Just to add, this solution worked to solve this particular problem, but using trim="yes" wasn't enough to compact all the whitespace sufficiently for acceptance by the gwcode plugin. Instead, putting the whole stash:set section on a single line worked ok. (In reality, I worked with Alissa offline to come up with a more sensible solution based on custom fields instead of categories), but the technique above might help someone else one day. Apr 28, 2013 at 23:03
0

Try group_id instead of cat_group_id

1
  • Yes, I did try that as well and it doesn't work. Apr 22, 2013 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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