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.

Searching custom fields

October 01, 2010 6:50am

Subscribe [3]
  • #1 / Oct 01, 2010 6:50am

    kyan

    11 posts

    Hey,

    We have an EE site up and running. It has a Channel called “Establishments” which has a number of custom fields, some of which are set as “searchable” in the preferences. My search form, however, does not seem to look at these fields during the process and im not receiving the results i would expect from my content.

    I am right in thinking that a search form in EE can be used to search custom fields that have been marked as “searchable”, right?

    Here is my form:

    <div id="refine_search">
        {exp:search:advanced_form result_page="establishments/search_results" channel="Establishments" results="6" status="open"}
            <h2>Refine search results</h2>
    <p>        {embed="shared/search_fields"}<br />
            <fieldset class="buttons"><br />
                <input type="image" class="submit" alt="Refine results" src="/images/build_images/button_refine_results.png" /><br />
            </fieldset><br />
        {/exp:search:advanced_form}<br />
    </div>

    The search fields:

    <fieldset>
        <div>
            <label for="keywords">Enter keywords</label>
            <input type="text" class="text default-value" id="keywords" name="keywords" value="Keywords.." />
    <input type="hidden" name="order_by_location" value="yes" />
        </div>
        <div>
            <label for="place">Establishment type</label>
            <select id="place" name="cat_id[]">
                <option value="all">All</option>
            {exp:channel:categories  style="linear"  channel="establishments" category_group="4" parent_only="yes"}
    
    <option value="{category_id}">{category_name}</option>
    
    {/exp:channel:categories}
            </select>
        </div>
        <div>
            <label for="parking">Parking</label>
            <select id="parking" name="cat_id[]">
                <option value="all">Any</option>
                <option value="121">With Parking</option>
            </select>
        </div>
        <div>
            <label for="location">Location</label>
            <select id="location" name="cat_id[]">
                    <option value="all">All</option>
            {exp:channel:categories  style="linear"  channel="establishments" category_group="10" show_empty="no"}
    
    <option value="{category_id}">{if parent_id !=0} - {/if}{category_name}</option>
    
    {/exp:channel:categories}
            </select>
        </div>
        <div>
            <label for="location">Facilities</label>
            <select id="location" name="cat_id[]">
                    <option value="all">All</option>
                        {exp:channel:categories  style="linear"  channel="establishments" category_group="7" show_empty="no"}
                            <option value="{category_id}">{if parent_id !=0} - {/if}{category_name}</option>
                        {/exp:channel:categories}
            </select>
        </div>
    </fieldset>

    Any help much appreciated, thanks.

  • #2 / Oct 01, 2010 5:02pm

    Sue Crocker

    26054 posts

    Hi, kyan. Unless you specify otherwise, EE will just search titles. (For a speedier return.)

    See the docs here: http://ellislab.com/expressionengine/user-guide/modules/search/simple.html#par_search_in

    Use search_in to include custom fields. (Either entries or everywhere)

    Does that help?

  • #3 / Oct 04, 2010 5:26am

    kyan

    11 posts

    Thanks, that helps a lot and works a treat. The assumption made was that those parameters would only work on the “Simple form tag” when in fact we are using the “Advanced form tag”.

    Thank you.

  • #4 / Oct 04, 2010 2:04pm

    Brandon Jones

    5500 posts

    Glad Sue helped, kyan!

    Don’t hesitate with further questions.

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

ExpressionEngine News!

#eecms, #events, #releases