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.

Simple Search Form: no_result_page doesn't work

February 01, 2012 12:04pm

Subscribe [1]
  • #1 / Feb 01, 2012 12:04pm

    bottleboot

    54 posts

    So I have this simple form:

    <div id='search'>
            
            {exp:search:simple_form channel="news|help" result_page="search/results" no_result_page="search/results"}
                    <span class="s_wrap">
                            <input type="text" name="keywords" id="keywords" value="search" size="18" maxlength="100" class="s_field"/>
                            <input type="submit" value="submit"/>
                    </span>
            {/exp:search:simple_form}
    </div>

    I do go to the results page when I have results but when i have no results i keep getting a no results message on a different page than the template I specified.

    On the search/results page I have:

    {exp:search:search_results switch="resultRowOne|resultRowTwo"}
                    {if total_results > 0}
                          Hurray
                    {if:else}
                          Boo!
                    {/if}
    {/exp:search:search_results}

    I must say that I do have the CSM plugin but it’s not turned on on these pages.

  • #2 / Feb 02, 2012 5:15pm

    bottleboot

    54 posts

    No one any ideas??

  • #3 / Feb 02, 2012 5:28pm

    Dan Decker

    7338 posts

    Hi bottleboot,

    I’m sorry you having trouble with simple search feature. can you please tell me which version of ExpressionEngine you are experiencing this with? If you specify a template other than the same one for results, does the parameter work as expected? I just want to rule out using the same template for both parameters as the culprit here.

    Thanks!

  • #4 / Feb 03, 2012 10:27am

    bottleboot

    54 posts

    Hi Dan!
    Thanks for your reply.

    When i change ‘the no_result_page’ tag to a different template, it does work again!
    It would be nice if I could use one template though for both though. This way I don’t have to change two templates each time, but just can differentiate with some if statements.

    We’re running the previous version, v2.3.1 , we’ll be upgrading to the next version together with other upgrades I’m working on now. Do you think this issue will be solved after the upgrade?

  • #5 / Feb 03, 2012 11:03am

    bottleboot

    54 posts

    If I get rid of the

    {exp:search:search_results switch="resultRowOne|resultRowTwo"}

    tags it all works again.

    Of course I don’t have results anymore.

    But otherwise i get this

    "Search Results:
    Your search did not return any results."

    Al I want is this:

    {exp:search:search_results switch="resultRowOne|resultRowTwo"}
    {if results} 
       ->results
    {if:else}
       ->message
    {/if}
    {/exp:search:search_results}

    All on the same page.

     

  • #6 / Feb 03, 2012 11:38am

    bottleboot

    54 posts

    Conditionals also seem to have no effect:

    {exp:search:total_results}
            {if total_results > 0}
                    yes
                    
            {if:else}
                    no
            {/if}
    {/exp:search:total_results}
  • #7 / Feb 03, 2012 11:57am

    bottleboot

    54 posts

    So i derived this from the “User Contributed Notes”:

    {if "{exp:search:total_results}" >= 1}
       yes
    {if:else}
       no
    {/if}

    This does work! HOWEVER

    This:

    {if "{exp:search:total_results}" >= 1}
       {exp:search:search_results switch="resultRowOne|resultRowTwo"}
          {title}
       {/exp:search:search_results}  
    {if:else}
       no
    {/if}

    Gives me the same

    "Search Results:
    Your search did not return any results."

    Basically when there are no results and there is the
    “{exp:search:search_results}” tag on the no_results page you get a system message instead of your template. Even if the tag is wrapped in the conditional which works by it self!

    When there are no results

  • #8 / Feb 03, 2012 12:28pm

    bottleboot

    54 posts

    This does work:

    {if "{exp:search:total_results}" == 0}
            no results
    {if:else}
            yes we have results
            {embed="search/yesresults"}
    {/if}

    With the {exp:search:search_results} in the embedded files.

    Now we do have two templates again though :/.
    Isn’t the whole point of using a cms and templates that you don’t have to make a html file for each page?

  • #9 / Feb 06, 2012 6:08pm

    Sean C. Smith

    3818 posts

    bottleboot,

    I’m sorry for your frustration about this. It appears that this is the way the search results tag has been coded. You’re more than welcome to make a Feature Request to get it working the way you expect. Is there anything else I can assist you with?

    Sean

  • #10 / Feb 07, 2012 2:56pm

    bottleboot

    54 posts

    Thanks Sean.

    Too bad. I made a feature request.
    Is there anyway this could be added to the docs? It could save somebody else the time it took me to look for this?

  • #11 / Feb 10, 2012 6:01pm

    Sean C. Smith

    3818 posts

    Bottleneck,

    I’ll inform the team responsible for the docs. I’m going to close out this thread, but feel free to post again when you have more questions.

    Sean

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

ExpressionEngine News!

#eecms, #events, #releases