<p>If i'm not mistaking, craft.request.getQuery() returns an array filled with all $_GET key-value pairs, so in your case:</p>

<pre><code>{% set queryParams = craft.request.getQuery() %}
</code></pre>

<p>will let you do:</p>

<pre><code>// Do with it what you like ...
{% set queryParams = queryParams | without(key) %} // Removes a param
{% set queryParams = queryParams | merge([{ 'limit' : 10 }]) %} // Adds a param
{% set queryParams['order'] = 'price' %} // Changes a param
</code></pre>

<p>After doing what you need to do, you can rebuild the query string:</p>

<pre><code>{% set queryString = '' %}
{% for key, value in queryParams %}
    {% set queryString = loop.first ? '?' ~ key ~ '=' ~ value : '&amp;amp;' ~ key ~ '=' ~ value %}
{% endfor %}
{% redirect(siteUrl ~ queryString) %}
</code></pre>

CC BY-SA 3.0
2014-09-11T14:40:55.233Z
2014-09-11T14:40:55.233Z
Paul
<p>How do you add extra parameters or update a parameter to an exiting POST URL?</p>

<p><strong>ADD EXTRA PARAMETER</strong></p>

<p>For example, I have a page at this address:</p>

<pre><code>http://localhost/shop/?color=red&amp;order=title
</code></pre>

<p>And in my twig I want to add a parameter like this:</p>

<pre><code>http://localhost/shop/?color=red&amp;order=title&amp;sort=asc
http://localhost/shop/?color=red&amp;order=title&amp;sort=asc&amp;limit=10
</code></pre>

<p><strong>UPDATE PARAMETER</strong></p>

<p>For example, I have a page at this address:</p>

<pre><code>http://localhost/shop/?color=red&amp;order=title
</code></pre>

<p>And in my twig I want to update a parameter like this:</p>

<pre><code>http://localhost/shop/?color=blue&amp;order=title
http://localhost/shop/?color=red&amp;order=price
</code></pre>

<url><request>
Update and add POST URL parameters
# Update and add POST URL parameters

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

How do you add extra parameters or update a parameter to an exiting POST URL?
ADD EXTRA PARAMETER
For example, I have a page at this address:
http://localhost/shop/?color=redℴ=title

And in my twig I want to add a parameter like this:
http://localhost/shop/?color=redℴ=title&sort=asc
http://localhost/shop/?color=redℴ=title&sort=asc&limit=10

UPDATE PARAMETER
For example, I have a page at this address:
http://localhost/shop/?color=redℴ=title

And in my twig I want to update a parameter like this:
http://localhost/shop/?color=blueℴ=title
http://localhost/shop/?color=redℴ=price

**Tags:** url, request

---

## 1 answers

### Answer by username_1 on 2014-09-11. Score: 4

If i'm not mistaking, craft.request.getQuery() returns an array filled with all $_GET key-value pairs, so in your case:
{% set queryParams = craft.request.getQuery() %}

will let you do:
// Do with it what you like ...
{% set queryParams = queryParams | without(key) %} // Removes a param
{% set queryParams = queryParams | merge([{ 'limit' : 10 }]) %} // Adds a param
{% set queryParams['order'] = 'price' %} // Changes a param

After doing what you need to do, you can rebuild the query string:
{% set queryString = '' %}
{% for key, value in queryParams %}
    {% set queryString = loop.first ? '?' ~ key ~ '=' ~ value : '&' ~ key ~ '=' ~ value %}
{% endfor %}
{% redirect(siteUrl ~ queryString) %}


---

