2

Basically, I didn't need anything fancy. The simple example with some stripped out pieces would suffice, but I would like them to be able to simple search all entries by author, or any other segment for that matter. The problem I run into is every time I submit the search, I am told "You did not submit a search term." from the standard EE error screen. I have usually just built my searches but figured it would be better to use the search module as is rather than allowing PHP.

My template is as follows. Am I missing something simple here?

{exp:search:advanced_form result_page="search/results" no_result_page="search/no_results" channel="blog_post" status="not_closed" search_in="everywhere" where="all" show_expired="no" show_future_entries="no"}
    <table cellpadding='4' cellspacing='6' border='0' width='100%' style="margin: 1em 0 0 0;">
        <tr>
            <td colspan="2">
                <fieldset class="fieldset">
                    <legend>{lang:search_by_keyword}</legend>
                    <input type="text" class="input" maxlength="250" name="keywords" style="width:100%;" />
                </fieldset>
            </td>
        </tr>
    </table>
    <table cellpadding='4' cellspacing='6' border='0' width='100%' style="margin: 1em 0 0 0;">
        <tr>
            <td width="50%">
                <fieldset class="fieldset">
                    <legend>Search by Author</legend>
                    <div class="default">
                        <select name="where">
                            <option value="any" selected="selected">Any</option>
                            {snippet_active_authors}
                        </select>
                    </div>
                </fieldset>
            </td>
            <td width="50%">
                <fieldset class="fieldset">
                    <div class="defaultBold">{lang:categories}</div>
                    <select name='cat_id[]' size='5'  class='multiselect' multiple='multiple'>
                        <option value='all' selected="selected">{lang:any_category}</option>
                        {snippet_active_categories}
                    </select>
                </fieldset>
            </td>
        </tr>
    </table>
    <table cellpadding='4' cellspacing='6' border='0' width='100%' style="margin: 1em 0 0 0;">
        <tr>
            <td valign="top" width="50%">
                <fieldset class="fieldset">
                    <legend>{lang:search_entries_from}</legend>
                    <select name="date" style="width:150px">
                        <option value="0" selected="selected">{lang:any_date}</option>
                        <option value="1" >{lang:today_and}</option>
                        <option value="7" >{lang:this_week_and}</option>
                        <option value="30" >{lang:one_month_ago_and}</option>
                        <option value="90" >{lang:three_months_ago_and}</option>
                        <option value="180" >{lang:six_months_ago_and}</option>
                        <option value="365" >{lang:one_year_ago_and}</option>
                    </select>
                    <div class="default"><br /></div>
                    <div class="default">
                        <input type='radio' name='date_order' value='newer' class='radio' checked="checked" />&nbsp;{lang:newer}
                        <input type='radio' name='date_order' value='older' class='radio' />&nbsp;{lang:older}
                    </div>
                </fieldset>
            </td>
            <td valign="top" width="50%">
                <fieldset class="fieldset">
                    <legend>{lang:sort_results_by}</legend>
                    <select name="orderby">
                        <option value="date" >{lang:date}</option>
                        <option value="title" >{lang:title}</option>
                    </select>
                    <div class="default"><br /></div>
                    <div class="default">
                        <input type='radio' name='sort_order' class="radio" value='desc' checked="checked" /> {lang:descending}
                        <input type='radio' name='sort_order' class="radio" value='asc' /> {lang:ascending}
                    </div>
                </fieldset>
            </td>
        </tr>
    </table>
    <table cellpadding='4' cellspacing='6' border='0' width='100%' style="margin: 1em 0 0 0;">
        <tr>
            <td colspan="2">
                <fieldset class="fieldset">
                    <div class='searchSubmit' style="text-align: right;">
                        <input type='submit' value='Search' class='submit' />
                    </div>
                </fieldset>
            </td>
        </tr>
    </table>
{/exp:search:advanced_form}

Thanks all.

  • Just a guess here, but have you checked that your custom fields are marked 'searchable'? – erwinheiser Jan 16 '13 at 22:38
  • Yep. I ran through that and am searching all. – W3bGuy Jan 17 '13 at 3:38
1

If there isn't a member_name, a search term is required when using the native ExpressionEngine search tag so you must add the keyword field back in:

<input type="text" name="keywords" id="keywords" maxlength="100" size="20" />

If you don't want the keyword, you can hack the Search module to remove the code that requires the keyword or you can look at the paid search addons that are available: Super Search or Low Search.

|improve this answer|||||
  • I thought about that, but I really hate the idea of hacking core files unless I really have to. (More notes to keep for revisions, etc...) – W3bGuy Jan 17 '13 at 3:40
  • For clarification, I see you have a name="keywords" field in your form. Are you getting the error when a keyword is added to this field? – Anna_MediaGirl Jan 17 '13 at 4:10
  • nope. If I add that, I'm good. I would like the search to be open to any of the fields though. It seems like I can select any of the others, but I must have a keyword entered or the no keywords error is returned. – W3bGuy Jan 17 '13 at 16:26
  • Keyword I'd absolutely required for the search tag. My original answer stands. Hack or addons are your only options. – Anna_MediaGirl Jan 17 '13 at 16:33

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.