3

I’m running into some issues when my users are searching using Simple Search and get no results. For some reason, they’re being redirected to a system message which is detailing they don’t have any results. However, this isn’ the correct template, and certain embeds are showing that shouldn’t be, and as a result are not rendering properly. The search form is inside of a snippet called snip_primary_nav, shown here:

<nav id="social">
    <ul>
        <li><a href="http://www.youtube.com/user/HeirloomMeals"><img src="/assets/images/youtube_16.png" alt="Youtube" width="16" height="16" /></a></li>
        <li><a href="http://twitter.com/HeirloomMeals"><img src="/assets/images/twitter_16.png" alt="Twitter" width="16" height="16" /></a></li>
        <li><a href="/rss/"><img src="/assets/images/rss_16.png" alt="RSS" width="16" height="16" /></a></li>
        {!-- <li><a href="http://www.linkedin.com/company/heirloom-meals"><img src="/assets/images/linkedin_16.png" alt="LinkedIn" width="16" height="16" /></a></li> --}
        <li><a href="http://pinterest.com/heirloommeals"><img src="/assets/images/pinterest_16.png" alt="Pinterest" width="16" height="16" /></a></li>
        <li><a href="http://instagram.com/heirloommeals"><img src="/assets/images/instagram_16.png" alt="Instagram" width="16" height="16" /></a></li>
        <li><a href="http://www.facebook.com/HeirloomMealsWithCaroleMurko"><img src="/assets/images/facebook_16.png" alt="Facebook" width="16" height="16" /></a></li>          
    </ul>

{exp:search:simple_form channel="blog|shows|recipes|products" search_in="everywhere" where="all" result_page="search/" no_result_page="search/no_results" show_expired="yes" show_future_entries="yes"}

<input type="text" name="keywords" id="keywords" value="" size="18" maxlength="100" />
<input type="submit" value="" class="searchbtn" />

{/exp:search:simple_form}
<div class="question-call-to-action"><span>Questions?</span><br />Call 413-298-0173</div>
</nav>

This is called inside of a general template, but happens on every template similarly:

{embed="_includes/.header"}
    <header>
{gv_logo}
{snip_ribbon}
{snip_primary-nav}
    </header>
  <div id="container">
        <div id="banner">
        <h2 id="sig">With Carole Murko</h2>
            <div id="slider">
            {lv_home_headers}
            </div>
        </div>

        <div id="content">
        <section id="col1">
            <h1>{lv_home_col1_heading}</h1>
            <div class="divide">
            {lv_home_col1_content}
            </div>
        </section>

        <section id="col2">
            <h2>{lv_home_col2_heading}</h2>
            <div class="divide">
            {exp:low_variables:parse var="lv_home_col2_content"}
            </div>
        </section>

        <section id="col3">
            <h2>News</h2>
            <article class="highlight">
            {exp:channel:entries channel="blog" limit="1" category="16" disable="member_data|pagination"}
                <h3><a href="{title_permalink='blog/'}">{title}</a></h3>{exp:replace_plus find="class=:QUOTE:highlight:QUOTE:"}{body}{/exp:replace_plus}
            {/exp:channel:entries}
            </article>
            {gv_subscribe}
        </section>
        </div>
  </div> <!-- end of #container -->
{gv_footer}
{snip_footer}

I thought maybe I had an open search tag like Adam Wiggall did in this post: (Incorrect no_results page returned for simple search) but after a quick search, I don’t see any other tags that aren’t closed.

Has anyone run into this sort of issue before? My template revisions are off, using files, and templates are synced with files.

  • Have you tried to open the templates right on URL? – Robson Sobral May 29 '13 at 23:20
  • Yes. The template loads just fine. :( – Christopher Kennedy May 30 '13 at 2:35
  • Please, how are the embeds showing if the users are being redirect to a system message? Please, give us more details. – Robson Sobral May 31 '13 at 0:52
  • You are looking at the snippet, right above. There isn’t much more to it. – Christopher Kennedy Jun 2 '13 at 19:02
  • I'm sorry, but I prefer to see the templates of the search group, please. – Robson Sobral Jun 2 '13 at 21:54
4

It's a bug in EE's native Search module. Bug reported here: https://support.ellislab.com/bugs/detail/19828

Here's the fix:

Starting in line 1290 of system/expressionengine/modules/search/mod.search.php

REPLACE

if ($query->num_rows() == 0 OR $query->row('total_results')  == 0)
{
  return ee()->output->show_user_error('off', array(lang('search_no_result')), lang('search_result_heading'));
}

WITH

if ($query->num_rows() == 0 OR $query->row('total_results')  == 0)
{           
  if ($query->row('no_result_page') == "")
  {
    return ee()->output->show_user_error('off', array(lang('search_no_result')), lang('search_result_heading'));
  }
  else
  {
    $path = reduce_double_slashes(ee()->functions->create_url(trim_slashes($this->_meta['no_result_page'])).'/'.$hash.'/');
    ee()->security->restore_xid();
    return ee()->functions->redirect($path);
  }
}
| improve this answer | |
  • Excellent! Just the fix I was looking for. Thank you, kindly, Stephen! – Christopher Kennedy Oct 22 '13 at 15:07
  • It looks like this fix got reverted sometime between versions 2.7 and 2.10, as it's no longer part of the source code. – mopo922 Feb 28 '17 at 17:24

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.