0

I have a zoo visitor channel for all my members. My zoo visitor has multiple category groups. I am trying to create a category drop filter menu to filter the members by category. In the drop menu I need each group name displayed and then all the categories:

ie: Filter by Category:

--Category Name A--

Category 1

Category 2

--Category Name B--

Category 1

Category 2

The 2 categories I am using right now are group ID 39 and 41

<form name="catmenu" action="">
  <select name="selcat" onchange="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;">
  <option value="">Filter by Category</option>
  {exp:channel:categories cache="yes" refresh="60" channel="zoo_visitor" disable="category_fields" style="linear"}
{if parent_id == '39'}{if count != '1'}</optgroup>{/if}<optgroup label="{category_name}">{/if}
{if parent_id != '39'}<option value="{path='home/directory'}">{category_name}</option>{/if}
  {/exp:channel:categories}
 </select>
</form> 
2
  • I tried to help you, but I can't understand one thing. Are 39 and 41 categories or category groups? – Sobral Jun 5 '13 at 12:48
  • THEY ARE CAT GROUPS – Peter Eastwood Jun 5 '13 at 12:49
1

You don't need addons for this. Try to use addons just when you really need them.

<form name="catmenu" action="">
  <select name="selcat" onchange="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;">
  <option value="">Filter by Category</option>
    <optgroup label="group 39">
    {exp:channel:categories cache="yes" refresh="60" channel="zoo_visitor" disable="category_fields" style="linear" category_group="39" show_empty="no"}
        <option value="{path='home/directory'}">{category_name}</option>
    {/exp:channel:categories}
    </optgroup>
    <optgroup label="group 41">
    {exp:channel:categories cache="yes" refresh="60" channel="zoo_visitor" disable="category_fields" style="linear" category_group="41" show_empty="no"}
        <option value="{path='home/directory'}">{category_name}</option>
    {/exp:channel:categories}
    </optgroup>
 </select>
</form> 
2
  • another strange occurance. When I select a category the results page display all entries, not the ones dynamic to the segment_3 category: domain.com/index.php/directory/category/cat_name {exp:zoo_visitor:members limit="99" member_group="5" orderby="random" dynamic="yes"} <h2>{visitor:member_firstname} {visitor:member_lastname}</h2> {/exp:zoo_visitor:members} – Peter Eastwood Jun 5 '13 at 13:09
  • 1
    I'm sorry, but this is related to Zoo Visitor, not directly to channel:categories. Since I never used Zoo Visitor, I can't help you. – Sobral Jun 5 '13 at 13:17
0

GWCode categories seems to be of some help. Testing this right now:

<form name="catmenu" action="">
  <select name="selcat" onchange="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;">
  <option value="">Filter by Riding</option>
<optgroup label="Group 1">
{exp:gwcode_categories channel="zoo_visitor" entry_count="yes" group_id="39" excl_group_id="41" show_empty="no" style="linear"}
    <option value="{path="examplepath/{cat_url_title}"}">{cat_name} ({entry_count})</option> 
{/exp:gwcode_categories}
<optgroup label="Group 2">
{exp:gwcode_categories channel="zoo_visitor" entry_count="yes" group_id="41" excl_group_id="39" show_empty="no" style="linear"}
    <option value="{path="examplepath/{cat_url_title}"}">{cat_name} ({entry_count})</option>
{/exp:gwcode_categories}

 </select>
</form> 

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.