0

On a Website i use two category groups: Wine (White, Red, Rose etc) and Food (Burgers, Fish, Seafood etc)

First page has a dropdown with categories of Wine

<form>
    <select>
    <option value="">Wine</option>
    {exp:channel:categories 
        channel="product" 
        category_group="1" 
        show_empty="no" 
        style="linear"}
        <option value="{path='pages/vintyp'}">{category_name}</option>
    {/exp:channel:categories}
    </select>
</form>

Linking to second page with categories of Food

<form>
    <select>
    <option value="">Food</option>
    {exp:channel:categories 
        channel="product" 
        category_group="2" 
        show_empty="no" 
        style="linear"}
        <option value="{path='pages/vintyp'}">{category_name}</option>
    {/exp:channel:categories}
    </select>
</form>

{exp:channel:entries channel="product" orderby="post_date" sort="desc"}
{/exp:channel:entries}

This will show all the used categories from the category group, but how do i filter out to only show those that correspond the selection of the previous category group?

If select “White” on the first page only “Seafood and Fish” should be in the dropdown on the second page If i select “Red” on the first page only “Burgers” should be in the dropdown.

Any help would be appreciated.

1

The only way that you could achieve this would be to include something that describes the relationship between wine choices and food types somewhere in your model - unless EE can find out what food types are associated with a chosen wine type it is going to be difficult to get the mapping you desire to appear automatically.

Fortunately EE includes a couple of powerful tools for you to consider.

Introducing either idea into your site will require some thought about how you want to make use of and represent this relationship data.

Making a guess based on what you describe, probably the best route is to use relationships rather than categories - you could do this by creating two shadow channels (e.g. one called wines, one called food_types) and set up a relationship field in wines that allows you to map food_type channel entries to each wine entry. This might require some re-working of the logic in other parts of the site to work, but in long run probably will give you a more flexible solution.

HTH

2
  • Perhaps Reefine could help you : devot-ee.com/add-ons/reefine – Stéphane Feb 16 at 4:23
  • 1
    Thank You HTH I went with Sub-categories. exp:channel:category_heading to get current category and exp:query to get the subcategories – Ralph Feb 18 at 10:19

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.