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

Filter categories in dropdown

How Do I?

Ralph Bartsch's avatar
Ralph Bartsch
31 posts
4 years ago
Ralph Bartsch's avatar Ralph Bartsch

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.

       
Ralph Bartsch's avatar
Ralph Bartsch
31 posts
4 years ago
Ralph Bartsch's avatar Ralph Bartsch

I solved this using exp:channel:category_heading to get current category and exp:query to get the subcategories.

👍 1
       

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.