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.

Search Results: Results and No Results Served by One Template?

July 03, 2012 11:35am

Subscribe [2]
  • #1 / Jul 03, 2012 11:35am

    I must be missing something obvious, but, how can I use a single template to serve search results when results are and aren’t found?

    I’m building a search form like this, using the no_result_page parameter:

    {exp:search:simple_form channel="news|pages" result_page="search/index" search_in="everywhere" no_result_page="search/index"}

    I tried the following, but, I don’t get any output from within {exp:search:search_results}.

    {exp:search:total_results}
     {if "{total_results}" != "0"}
      {exp:search:search_results}
       {title}, etc.
      {/exp:search:search_results}
     {/if}
    {/exp:search:total_results}

    ... if I don’t nest {exp:search_results} within that conditional, I get the ugly “Search Results: Your search did not return any results.” system message.

    What am I missing? Surely there’s a conditional I can nest {exp:search:search_results} within that won’t bork the template.

  • #2 / Jul 03, 2012 12:13pm

    Dom Stubbs

    156 posts

    I’m fairly sure you have to setup a separate static ‘no results’ template. Try to combine the two and EE will fall over. In the no results page you can use {exp:search:keywords} to make things a little dynamic, e.g.

    We have been unable to find any results for '{exp:search:keywords}'
  • #3 / Jul 04, 2012 11:48am

    Dan Decker

    7338 posts

    Hi Nick,

    Indeed, Dom is correct. The no-results template should be separate and distinct.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases