<p>Looking at the example from the <a href="https://putyourlightson.com/sprig-cookbook#search" rel="nofollow noreferrer">Sprig Cookbook</a>, it looks like the results container should live outside the <code>sprig.isInclude</code>:</p>
<pre><code>{% if sprig.isInclude %}
    &lt;select sprig s-target=&quot;#results&quot; name=&quot;verdict&quot; id=&quot;verdict&quot;&gt;
        {# loop through options #}
    &lt;/select&gt;
    &lt;select sprig s-target=&quot;#results&quot; name=&quot;rating&quot; id=&quot;rating&quot;&gt;
        {# loop through options #}
    &lt;/select&gt;
    &lt;select sprig s-target=&quot;#results&quot; name=&quot;platform&quot; id=&quot;platform&quot;&gt;
        {# loop through options #}
    &lt;/select&gt;
    &lt;input sprig s-trigger=&quot;keyup changed&quot; s-target=&quot;#results&quot; type=&quot;search&quot; name=&quot;title&quot; id=&quot;title&quot; /&gt;
{% endif %}

&lt;div id=&quot;results&quot;&gt;
{% if queryParams %}
    {% set entries = craft.entries(queryParams).orderBy('score').all() %}
    {% for entry in entries %}
        {{ entry.title }}
    {% endfor %}
{% else %}
    {% set entries = craft.entries.section('games').orderBy('title').all() %}
    {% for entry in entries %}
        {{ entry.title }}
    {% endfor %}
{% endif %}
&lt;/div&gt;
</code></pre>

CC BY-SA 4.0
2020-09-14T07:18:59.860Z
Thank you, that was it. Can't believe I didn't try that before.
darylknight
CC BY-SA 4.0
2020-09-17T06:31:36.803Z
Updated the answer to use the new `sprig.isInclude` syntax as of beta 15.
Ben Croker
CC BY-SA 4.0
2020-09-14T03:51:11.947Z
2020-09-17T06:31:14.193Z
2020-09-17T06:31:14.193Z
raptureaid
<p>I want to display all results in the games section to start with, then once you search, it shows the filtered results. Sprig's starting point I think assumes that you're showing nothing, like a normal search box.</p>
<p>With the code below, it shows all results to start with - but once there's a search query, it shows the filtered results, then also ALL of the results underneath those. What do I need to change to show all results first and REPLACE them with the filtered results after searching?</p>
<p>It's something to do with the s-target stuff I think. The original loop gets 'moved' into #results when you search, but as I don't understand how Sprig works so I don't really know why it's doing it</p>
<pre><code>{% set queryParams = {} %}
{% set relatedParams = ['and'] %}

{# This is where the query logic is -combining category filters and text search etc #}

{% if sprig.include %}
    &lt;select sprig s-target=&quot;#results&quot; name=&quot;verdict&quot; id=&quot;verdict&quot;&gt;
        {# loop through options #}
    &lt;/select&gt;
    &lt;select sprig s-target=&quot;#results&quot; name=&quot;rating&quot; id=&quot;rating&quot;&gt;
        {# loop through options #}
    &lt;/select&gt;
    &lt;select sprig s-target=&quot;#results&quot; name=&quot;platform&quot; id=&quot;platform&quot;&gt;
        {# loop through options #}
    &lt;/select&gt;
    &lt;input sprig s-trigger=&quot;keyup changed&quot; s-target=&quot;#results&quot; type=&quot;search&quot; name=&quot;title&quot; id=&quot;title&quot; /&gt;
    &lt;div id=&quot;results&quot;&gt;&lt;/div&gt;
{% endif %}

{% if queryParams %}
    {% set entries = craft.entries(queryParams).orderBy('score').all() %}
    {% for entry in entries %}
        {{ entry.title }}
    {% endfor %}
{% else %}
    {% set entries = craft.entries.section('games').orderBy('title').all() %}
    {% for entry in entries %}
        {{ entry.title }}
    {% endfor %}
{% endif %}
</code></pre>

<plugin-sprig>
Using Sprig's live search but show all entries first
# Using Sprig's live search but show all entries first

(Asked by: username_0 on 2020-09-13)

I want to display all results in the games section to start with, then once you search, it shows the filtered results. Sprig's starting point I think assumes that you're showing nothing, like a normal search box.
With the code below, it shows all results to start with - but once there's a search query, it shows the filtered results, then also ALL of the results underneath those. What do I need to change to show all results first and REPLACE them with the filtered results after searching?
It's something to do with the s-target stuff I think. The original loop gets 'moved' into #results when you search, but as I don't understand how Sprig works so I don't really know why it's doing it
{% set queryParams = {} %}
{% set relatedParams = ['and'] %}

{# This is where the query logic is -combining category filters and text search etc #}

{% if sprig.include %}
    
        {# loop through options #}
    
    
        {# loop through options #}
    
    
        {# loop through options #}
    
    
    
{% endif %}

{% if queryParams %}
    {% set entries = craft.entries(queryParams).orderBy('score').all() %}
    {% for entry in entries %}
        {{ entry.title }}
    {% endfor %}
{% else %}
    {% set entries = craft.entries.section('games').orderBy('title').all() %}
    {% for entry in entries %}
        {{ entry.title }}
    {% endfor %}
{% endif %}

**Tags:** plugin-sprig

---

## 1 answers

### Answer by username_1 on 2020-09-14. Score: 3 | Accepted answer

Looking at the example from the Sprig Cookbook, it looks like the results container should live outside the sprig.isInclude:
{% if sprig.isInclude %}
    
        {# loop through options #}
    
    
        {# loop through options #}
    
    
        {# loop through options #}
    
    
{% endif %}


{% if queryParams %}
    {% set entries = craft.entries(queryParams).orderBy('score').all() %}
    {% for entry in entries %}
        {{ entry.title }}
    {% endfor %}
{% else %}
    {% set entries = craft.entries.section('games').orderBy('title').all() %}
    {% for entry in entries %}
        {{ entry.title }}
    {% endfor %}
{% endif %}

> **Comments:**
> **username_0**: Thank you, that was it. Can't believe I didn't try that before.  
> **username_2**: Updated the answer to use the new `sprig.isInclude` syntax as of beta 15.  

---

