<p>You could use a conditional to check if your "search term" parameter has a value. </p>

<pre><code>&lt;h1&gt;Search Results&lt;/h1&gt;

{% set query = craft.request.getParam('q') %}

{% if query|length  %}

    {% set entries = craft.entries.search(query).order('score') %}

    {% if entries|length %}
        &lt;p&gt;{{ entries|length }} results:&lt;/p&gt;

        &lt;ul&gt;
            {% for entry in entries %}
                &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
            {% endfor %}
        &lt;/ul&gt;
    {% else %}
        &lt;p&gt;Your search for “{{ query }}” didn’t return any results.&lt;/p&gt;
    {% endif %}


{% else %}
    &lt;p&gt;You forgot to enter a search term.&lt;/p&gt;
{% endif %}
</code></pre>

<p>(This code is modified from the examples in the <a href="http://buildwithcraft.com/docs/templating/search-form" rel="nofollow">Craft docs for "Search Form"</a>)</p>

CC BY-SA 3.0
2015-04-22T16:48:44.130Z
2015-04-22T17:01:27.080Z
2015-04-22T17:01:27.080Z
Dylan T
<p>When you click in search form and press 'Enter' or 'Submit' button, it returns all entries, that exist in database.</p>

<p>How could I display some message rather than all entries?</p>

<search>
Search result on blank search query
# Search result on blank search query

(Asked by: username_0 on 2015-04-22)

When you click in search form and press 'Enter' or 'Submit' button, it returns all entries, that exist in database.

How could I display some message rather than all entries?

**Tags:** search


---

## 1 answers

### Answer by username_1 on 2015-04-22. Score: 2 | Accepted answer

You could use a conditional to check if your "search term" parameter has a value. 
Search Results

{% set query = craft.request.getParam('q') %}

{% if query|length  %}

    {% set entries = craft.entries.search(query).order('score') %}

    {% if entries|length %}
        {{ entries|length }} results:

        
            {% for entry in entries %}
                {{ entry.title }}
            {% endfor %}
        
    {% else %}
        Your search for “{{ query }}” didn’t return any results.
    {% endif %}


{% else %}
    You forgot to enter a search term.
{% endif %}

(This code is modified from the examples in the Craft docs for "Search Form")


---

