0

I have created a simple_form for a search bar in a sidebar. I can view it in the debugger and it highlights when I submit but nothing happens. I have added a result_page and a no_result_page but nothing occurs. I would expect to hit one of those pages upon submission but nothing happens?

{exp:search:simple_form 
            channel="articles" 
            result_page="search/results" 
            no_result_page="articles"
            results="10" 
            show_future_entries="no" 
            status="open" 
            where="any"
            }
    <input type="search" class="form-control" id="exampleInputEmail1" placeholder="Search">
    <input type="submit" value="submit" class="submit">
{/exp:search:simple_form}

Any ideas why its not submitting anywhere? Ive checked and the search module is installed.

0

Are you getting a standard error message something like "You did not submit a search term"??

This is the first step, your search keywords field needs to be named and ID'd keywords so :

<input type="search" class="form-control" id="keywords" name="keywords" placeholder="Search">

Once I do this my search form submits without errors, in fact as I have no articles channel it forwards me to /articles/[SEARCHKEY] i.e. no results...

My recommendation is to start with the documented form and alter it to your needs, testing results/no results as you go : https://ellislab.com/expressionengine/user-guide/add-ons/search/simple.html

Edit : Additionally

I note your no results path is just /articles, note that simple search will append the search key to your URL, so on no results will go to /articles/SOMEALPHANUMSTRING. I assume you have a Template group called "articles" however wit hthe presence of the search key this will casue EE to look for a template called whatever the search key is. To get around this, make sure you set up your index template with the route path of articles/{searchkey} or similar, this will allow the search key to pass through.

If you use a scheme like articles/url_title to also display individual articles, on this single view template set your route to articles/{article_url_title} and make sure this route happens before your article listing /no results route in the route manager.

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.