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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 04:27:54
Script start
Timing: Jan 31 2025 04:27:54
Module start 'layout'
Timing: Jan 31 2025 04:27:54
Module start 'content'
Timing: Jan 31 2025 04:27:54
Module end 'content'
Timing: Jan 31 2025 04:27:54
Script end

Main resources:

Total runtime0.0263 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0112 588.3750151.2422
Module start 'layout' 0.01120.0028 739.617236.7109
Module start 'content' 0.01400.0108 776.328194.3438
Module end 'content' 0.02480.0016 870.671937.9922
Script end 0.0263  908.6641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00269.7216140.0002
Check MTime0.00114.1028140.0001
Mysql Total
Database connection0.00062.164110.0006
Mysqli_queries0.006625.047530.0022
Looping result0.00000.038010.0000
Template Total0.00114.110.0011
Template load0.00083.037510.0008
Template processing0.00031.048110.0003
Override
Cache load0.00052.041910.0005
General
dbfile0.00269.846580.0003
String conversion0.00000.034440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs