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 %}
            <h1>{{ entry.title }}</h1>
            {{ entry.body }}
    {% endfor %}

    {% if paginate.prevUrl %}
        <a href="{{ paginate.prevUrl }}">Previous Page</a>
    {% endif %}

    {% if paginate.nextUrl %}
        <a href="{{ paginate.nextUrl }}">Next Page</a>
    {% endif %}
{% endpaginate %}

1 Answer 1


Try using this (completely untested):

{% if paginate.prevUrl %}
    <a href="{{ paginate.prevUrl }}?{{ craft.request.getQueryStringWithoutPath() }}">Previous Page</a>
{% endif %}

{% if paginate.nextUrl %}
    <a href="{{ paginate.nextUrl }}?{{ craft.request.getQueryStringWithoutPath() }}">Next Page</a>
{% endif %}


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.

  • Thanks but that didn't work. Throws this error: 'Method "getQueryStringWithoutPath" for object "Craft\HttpRequestVariable" does not exist'
    – Kyle
    Commented Sep 15, 2014 at 21:28
  • Gah... just realized that got added to the unreleased Craft 2.3.
    – Brad Bell
    Commented Sep 15, 2014 at 21:30
  • Updated answer.
    – Brad Bell
    Commented Sep 15, 2014 at 21:35
  • Hacking the core? That's some back-alley advice right there Brad. ;)
    – Lindsey D
    Commented Sep 15, 2014 at 22:38
  • 2
    – Brad Bell
    Commented Sep 15, 2014 at 22:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.