ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

multiple category dropdown search

August 29, 2011 5:55pm

Subscribe [3]
  • #1 / Aug 29, 2011 5:55pm

    realracine

    1 posts

    Hi there.

    I set up two category dropdown menu’s using the User Guide’s sample on this page: http://ellislab.com/expressionengine/user-guide/modules/channel/categories.html#dropdown

    I’ve been able to get it to mostly work, but being a newb to EE I’m still trying to figure things out. If anyone has any advice to get this working, I’d be very appreciative.

    My code is as follows:

    <form name="catmenu" action="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;">
      <select name="selcatrest">
        <option value="">Restaurant Type</option>
        {exp:channel:categories channel="places" style="linear" category_group="4"}
        <option value="{path='channel'}">{category_name}</option>
        {/exp:channel:categories}
      </select>
      <select name="selcatcuisine">
        <option value="">Cuisine Type</option>
        {exp:channel:categories channel="places" style="linear" category_group="5"}
        <option value="{path='channel'}">{category_name}</option>
        {/exp:channel:categories}
      </select>
      <input id="search"type="submit" value="Search" />
    </form>

    I know that the form action is wrong because I need it to search both <select> tags. That action is taken from the select onchange referenced in the User Guide link above. I just guessed since adding a search button that it would go in the form action.

    Thank in advance for your help!
    Tre Stange

  • #2 / Aug 29, 2011 8:03pm

    Boyink!

    5011 posts

    Are you looking to find entries that match choices in both the drop-downs?  If so, you’ll need an add-on for that. EE natively only reads one category from the URL to find matching entries.

    The add-on to look for is Low’s Seg2Cat.  It will let you create custom URL’s (using javascript, most likely in your case) with two category URL titles.  It will then give you variables to use in a channel:entries tag where you can specific category=”{variable_1} & {variable_2}”

  • #3 / Aug 29, 2011 8:13pm

    Hello.

    Yes, I’m wanting to find any and all entries that match the choice in either drowpdown menu. I will check out that add-on and let you know how it goes.

    Thank you.
    Tre Stange

  • #4 / Aug 29, 2011 8:20pm

    Boyink!

    5011 posts

    Just to be clear: It’s not a “multiple drop-downs” addon.

    What it is is a bridge between some custom URL’s that you will have to generate and EE’s native abilities.

    Basically the flow is:

    - User chooses a category in box 1 (green)
    - User chooses a category in box 2 (red)
    - User clicks submit
    - Javascript runs & creates a URL from boxes 1 & 2: http://www.mysite/products/green/red
    - Low’s Seg2Cat runs in the background and gives you variables that will grab segment_2 & segment_3, and return category_id’s from the category url titles.
    - The result template has standard EE code along the lines of

    {exp:channel:entries channel="products" category="{segment_2_id}&{segment_3id}" dynamic="no"}
    {title}
    {/exp:channel:entries}
  • #5 / Aug 30, 2011 3:56am

    John Henry Donovan

    12339 posts

    Hi Tre Stange ,
    Mike’s advice looks very useful. The thread is more appropriate for Community help though so moving it there where it will hopefully be useful for other members also.

  • #6 / Aug 30, 2011 10:50am

    Perfect.

    Thanks guys, this is gonna do just what I need. I’ll keep you posted on my implementation.

    Tre.

  • #7 / Sep 13, 2011 11:19am

    Hi again.

    I’m finally starting to implement this functionality and as a first time EE site builder, have a couple of more queries. I’ve installed, enabled and set Low Seg2Cat’s Category Groups to the two showing in the code I originally posted above. I guess I’m still confused about
      1. The proper action in the form “catmenu”
      2. The JavaScript Mike mentions that creates the URL from boxes 1 & 2.
      3. And finally where to put the code sample Mike generated. I’m thinking I might either have to create a new page/template that generates the results, or and a conditional to my already functioning search-results page.

    Any thoughts/specifics to help me flush this out is greatly appreciated. I think I’ve come a long way given the shear awesomeness that is EE, but I’ve still got the newb factor happening!
    Thanks all!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases