Forums / Setup & design / How to avoid "No results were found when searching for..."?

How to avoid "No results were found when searching for..."?

Author Message

Martin Crockett

Thursday 03 February 2005 8:51:01 am

The default search page displays the above message when visited.

It's a little confusing to first-time visitors.

How can I tweak the settings in the .tpl file to make it NOT display this message when the search page first loads?

Any help is gladly appreciated.

Eivind Marienborg

Thursday 03 February 2005 9:57:14 am

I would try mocking around with the searchresult-template. To override it, use this:

[searchresult]
Source=content/searchresult.tpl
MatchFile=searchresult.tpl
Subdir=templates

And of course create the correct template in your template dir..

Martin Crockett

Friday 04 February 2005 2:18:04 am

Unfortunately, the template is already being overwritten...

I need to stop the no results found message appearing on page load - when the user hasn't actually searched for anything yet.

If I don't get a decent reply, I'll add this to the list of unfathomable eZ Publish problems. ;-)

Roy Bøhmer

Sunday 06 February 2005 4:15:19 am

I've done a section show= to test if the user did write search-text or just clicked the button and used the default search-texkt "search text".

{section show=not(or(eq(0, $search_text|trim|count_chars), eq($search_text, 'search text')))}

Then you make a section-else to provide a deasent presentation if no words where provided by the user.

Andre Felipe Machado

Thursday 24 February 2005 3:42:10 pm

Hello,
Actually, it is already done on template search.tpl
You should create a template or override (according to your design) and include only the FIRST PART of search.tpl



{let search=false()}
{section show=$use_template_search}
    {set page_limit=10}
    {set search=fetch(content,search,
                      hash(text,$search_text,
                           section_id,$search_section_id,
                           subtree_array,$search_subtree_array,
                           sort_by,array('modified',false()),
                           offset,$view_parameters.offset,
                           limit,$page_limit))}
    {set search_result=$search['SearchResult']}
    {set search_count=$search['SearchCount']}
    {set stop_word_array=$search['StopWordArray']}
    {set search_data=$search}
{/section}

<form action={"/content/search/"|ezurl} method="get">

<div class="maincontentheader">
<h1>{"Search"|i18n("design/standard/content/search")}</h1>
</div>

<div class="block">
    <input class="halfbox" type="text" size="20" name="SearchText" id="Search" value="{$search_text|wash}" />
    <input class="button" name="SearchButton" type="submit" value="{'Search'|i18n('design/standard/content/search')}" />
</div>

<div class="block">
    {let adv_url=concat('/content/advancedsearch/',$search_text|count|gt(0)|choose('',concat('?SearchText=',$search_text|urlencode)))|ezurl}
    <label>{"For more options try the %1Advanced search%2"|i18n("design/standard/content/search","The parameters are link start and end tags.",array(concat("<a href=",$adv_url,">"),"</a>"))}</label>
    {/let}
</div>


</form>
{/let}

It works. I use it at my site.
Good luck.
Andre Felipe

---
A Debian user never dies. Issues a last command:
shutdown -h now

http://www.techforce.com.br