<p>Try using this (completely untested):</p>

<pre><code>{% if paginate.prevUrl %}
    &lt;a href="{{ paginate.prevUrl }}?{{ craft.request.getQueryStringWithoutPath() }}"&gt;Previous Page&lt;/a&gt;
{% endif %}

{% if paginate.nextUrl %}
    &lt;a href="{{ paginate.nextUrl }}?{{ craft.request.getQueryStringWithoutPath() }}"&gt;Next Page&lt;/a&gt;
{% endif %}
</code></pre>

<p><strong>Update:</strong></p>

<p>The above will only work once Craft 2.3 comes out.</p>

<p>In the meantime, it's a bit sketchy, but you can open up <code>craft/app/variables/HttpRequestVariable.php</code> and add this method:</p>

<pre><code>public function getQueryStringWithoutPath()
{
    return craft()-&gt;request-&gt;getQueryStringWithoutPath();
}
</code></pre>

<p>And it should work.  But please be aware that file could be overwritten by a 2.2 build release at any point during an auto-update and your template would break.</p>

CC BY-SA 3.0
2014-09-15T21:28:54.820Z
Thanks but that didn't work. Throws this error: 'Method "getQueryStringWithoutPath" for object "Craft\HttpRequestVariable" does not exist'
Kyle
CC BY-SA 3.0
2014-09-15T21:30:44.280Z
Gah... just realized that got added to the unreleased Craft 2.3.
Brad Bell
CC BY-SA 3.0
2014-09-15T21:35:58.833Z
Updated answer.
Brad Bell
CC BY-SA 3.0
2014-09-15T22:38:59.067Z
Hacking the core? That's some back-alley advice right there Brad. ;)
Lindsey D
CC BY-SA 3.0
2014-09-15T22:40:18.827Z
HACK THE PLANET
Brad Bell
CC BY-SA 3.0
2014-09-15T22:41:16.147Z
TBH, the OP can (and should) put that method into a custom plugin. Should work just as well, right?
Lindsey D
CC BY-SA 3.0
2014-09-15T22:42:12.237Z
Good point... will be much safer for updating.
Brad Bell
CC BY-SA 3.0
2014-09-15T21:26:29.380Z
2014-09-15T21:35:42.083Z
2014-09-15T21:35:42.083Z
Brad Bell
<p>I'm looking to paginate and array with multiple filters.</p>

<p>The current url would be: <code>www.example.com/search?filter=shorts&amp;type=leather&amp;brand=sams</code></p>

<p>Clicking on the next next link returns: <code>www.example.com/search/p2</code> effectively removing the search params.</p>

<p>Is there a way to paginate the full url without removing the search params?</p>

<pre><code>{% paginate test.limit(4) as entries %}
    {% for entry in entriesOnPage %}
        &lt;article&gt;
            &lt;h1&gt;{{ entry.title }}&lt;/h1&gt;
            {{ entry.body }}
        &lt;/article&gt;
    {% endfor %}

    {% if paginate.prevUrl %}
        &lt;a href="{{ paginate.prevUrl }}"&gt;Previous Page&lt;/a&gt;
    {% endif %}

    {% if paginate.nextUrl %}
        &lt;a href="{{ paginate.nextUrl }}"&gt;Next Page&lt;/a&gt;
    {% endif %}
{% endpaginate %}
</code></pre>

<search><pagination><params>
Paginate an array with multiple filters
# Paginate an array with multiple filters

(Asked by: username_0 on 2014-09-15)

I'm looking to paginate and array with multiple filters.
The current url would be: www.example.com/search?filter=shorts&type=leather&brand=sams
Clicking on the next next link returns: www.example.com/search/p2 effectively removing the search params.
Is there a way to paginate the full url without removing the search params?
{% paginate test.limit(4) as entries %}
    {% for entry in entriesOnPage %}
        
            {{ entry.title }}
            {{ entry.body }}
        
    {% endfor %}

    {% if paginate.prevUrl %}
        Previous Page
    {% endif %}

    {% if paginate.nextUrl %}
        Next Page
    {% endif %}
{% endpaginate %}

**Tags:** search, pagination, params


---

## 1 answers

### Answer by username_1 on 2014-09-15. Score: 6 | Accepted answer

Try using this (completely untested):
{% if paginate.prevUrl %}
    Previous Page
{% endif %}

{% if paginate.nextUrl %}
    Next Page
{% endif %}

Update:
The above will only work once Craft 2.3 comes out.
In the meantime, it's a bit sketchy, but you can open up craft/app/variables/HttpRequestVariable.php and add this method:
public function getQueryStringWithoutPath()
{
    return craft()->request->getQueryStringWithoutPath();
}

And it should work.  But please be aware that file could be overwritten by a 2.2 build release at any point during an auto-update and your template would break.

> **Comments:**
> **username_0**: Thanks but that didn't work. Throws this error: 'Method "getQueryStringWithoutPath" for object "Craft\HttpRequestVariable" does not exist'  
> **username_1**: Gah... just realized that got added to the unreleased Craft 2.3.  
> **username_1**: Updated answer.  
> **username_2**: Hacking the core? That's some back-alley advice right there Brad. ;)  
> **username_1**: HACK THE PLANET  
> **username_2**: TBH, the OP can (and should) put that method into a custom plugin. Should work just as well, right?  
> **username_1**: Good point... will be much safer for updating.  

---

