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.

Regarding Advanced Search Form

November 10, 2011 8:07am

Subscribe [2]
  • #1 / Nov 10, 2011 8:07am

    Tomas023

    7 posts

    Hello!

    regarding Advanced Search Form:
    we have multiple category groups connected to a channel; we want to show one select input element for each category for the user to choose from. The example at http://ellislab.com/expressionengine/user-guide/modules/search/advanced.html shows how to create a select input element that contains all categories from all category groups by using the {lang:any_category} tag and the ‘cat_id[]’ name; however there doesn’t seem to be any easily available documentation for this tag or related lang-tags.

    Is it possible to print out categories for the search form in other ways, using other lang-tags perhaps?

    Thanks /Thomas

  • #2 / Nov 10, 2011 9:07pm

    Dan Decker

    7338 posts

    Hi Tomas023,

    The {lang:} tags are special, in so much as they aren’t really tags like other ExpressionEngine template tags. They are used to pull the proper keys from ExpressionEngine’s language files which are used for localization. There really isn’t a list of these per se, but you can see them all in /system/expressionengine/language/english/

    Can you describe to me your desired goal, and I might be able to find a solution that works for you.

    Thanks!

  • #3 / Nov 11, 2011 3:09am

    Tomas023

    7 posts

    We are building an advertising site.
    There you should be able to search, we say cars (category) the state (category),
    then we have 2 diffrent channels, sale & buy ..

    We saw a plugin that may work, but we want to use exp so much we can.
    Any solution to this?

    Thanks /Thomas

  • #4 / Nov 12, 2011 7:33am

    Robin Sowell

    13255 posts

    Hrm- the short answer is no, but the long answer is probably yes.  Depending.  It should be pretty easy if the cars group is all on one level and so is the state- which sounds like they are.  That or if you want to hard code it.

    But quick note- it means you really can’t give them an ‘all’ option, because it will apply to all the categories.  Hrm.  Well, you could, but that would take an extension or more cleverness with js than I possess.  I can detail out why if you need me to- which you may.  Being able to select all cars seems like something folks might want to do (without having it mean ‘all states’ too.  But if not- no problem.

    Since cat_id is an array?  You can have multiple selects with that name.  So say hard coding it:

    <select name='cat_id[]' size='12'  class='multiselect' multiple='multiple'>
    <option value=''>Choose a Car</option>
    {exp:channel:categories channel="about" style="linear"}
    <option value='{category_id}'>{category_name}</option>
    {/exp:channel:categories}
    </select>
    
    <select name='cat_id[]' size='12'  class='multiselect' multiple='multiple'>
    <option value=''>Choose a State</option>
    {exp:channel:categories channel="news" style="linear"}
    <option value='{category_id}'>{category_name}</option>
    {/exp:channel:categories}
    </select>

    Do you understand the logic?  What will allow it to work is the fact the select has a name that’s an array.  So you put another select on there with the same name- it just adds it to the array and sends them all over together.

    Search is a little weird in that most of the cat select is populated via JS- because what goes in the field will depend on what category(s) they select.

    This is just really briefly tested and the logic is sound.  But I won’t swear there won’t be a few quirky bits depending on what you need to do (the ‘select all’ behavior being one.

    But does this look like it will work and do you understand the basic logic?

  • #5 / Nov 14, 2011 3:11am

    Tomas023

    7 posts

    Hello,

    thank you for your explanation and example; yes, we understand the logic of this solution and it will certainly work in our case.

  • #6 / Nov 15, 2011 11:20am

    Robin Sowell

    13255 posts

    Glad it makes sense- and I saw in my notification a question about whether two categories will do an ‘and’ search- do you still need clarification?  Also- just imagining how this will work a bit- if they aren’t going to be searching for actual text but instead you just want/need them to be able to select one or a combo of categories and have it ‘and’ search them?  I wouldn’t actually use the search- but rather a channel tag and some URL magic to pass the multiple cat identifiers.

    Anyway- sounds like the above is good, but want to make sure you’re on the right path for the overall goal of the site.

  • #7 / Nov 16, 2011 2:48am

    Tomas023

    7 posts

    Hi and thank you Robin Sowell;

    it is true that we still need more help with the Advanced Search form; we made a new post about it since it covers a different question; please, if you have time, take a look at:
    http://ellislab.com/forums/viewthread/204440/#953773

    Thanks!
    /Tomas

  • #8 / Nov 16, 2011 3:09pm

    Robin Sowell

    13255 posts

    Ah- will do.  Will follow up there!

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

ExpressionEngine News!

#eecms, #events, #releases