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.

no_results page not working in simple search

February 10, 2014 9:35am

Subscribe [2]
  • #1 / Feb 10, 2014 9:35am

    Bob K

    144 posts

    I’m building a site using v2.7.2 - Build Date: 20131008. My simple search is set up like this:

    {exp:search:simple_form channel="gallery" search_in="entries" result_page="search/gallery_results" no_result_page="content/not_found"}
            <h2>Search the Image Collections:</h2>
    
    <p>                <br />
            <input type="text" name="keywords" id="keywords" placeholder="Enter keywords" size="22" maxlength="100" class="search"></p>
    
    <p>        <input type="submit" class="go_button" value="Search"  ><br />
        <br />
    {/exp:search:simple_form}

    If I type in a valid search term, it all works fine. But if I type in a term that yields no results, my template doesn’t appear. Instead I get the standard “Search Results: Your search did not return any results. Return to Previous Page.” When I tap “return” and enter a new search term, I get: “The following errors were encountered. The action you have requested is invalid. Return to Previous Page.”

    The no_result template is in template_group/template format.

    Typically, when I’ve encountered an EE component that isn’t working, I’ve coded something incorrectly, but I can’t see my mistake on this one.

  • #2 / Feb 10, 2014 7:45pm

    DigitalDoctors

    76 posts

    Hmm seems weird - your code looks good, the only thing you could try is to add a ‘/’ at the start of the template paths e.g.

    {exp:search:simple_form channel="gallery" search_in="entries" result_page="/search/gallery_results" no_result_page="/content/not_found"}
  • #3 / Feb 10, 2014 8:13pm

    Bob K

    144 posts

    Indeed, very weird, DigitalDoctors. I originally had the slash in place, but it didn’t work that way, either. Also, the URL says it’s showing the correct no_result_page template (mysite.com/content/not_found), but the template itself is the standard one packaged with EE, not the one I designed.

    Thanks for the advice, though.

  • #4 / Feb 10, 2014 9:34pm

    Bob K

    144 posts

    Solved this problem.

    It wasn’t my simple search form coding, it was in the no_result_page coding. I tried to include this:

    {exp:search:keywords}

    as part of my template.

    The docs are not clear as to how this tag works, and it didn’t work as a stand alone, so I wrapped it in:

    {exp:search:search_results}
              {exp:search:keywords}
    {/exp:search:search_results}

    which is how the keywords display on the result_page template. However, the search_results tag is what caused all the confusion, so I went with this on the no_result_page instead:

    {exp:search:keywords}
              {exp:search:keywords}
    {/exp:search:keywords}

    and all is well with the world.

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

ExpressionEngine News!

#eecms, #events, #releases