<p>Use:</p>

<pre><code>{% if craft.request.getQueryString('success') %}
</code></pre>

<p><a href="https://craftcms.com/docs/templating/craft.request#getQueryString" rel="nofollow">https://craftcms.com/docs/templating/craft.request#getQueryString</a></p>

CC BY-SA 3.0
2016-03-31T22:09:47.680Z
2016-03-31T22:09:47.680Z
Brad Bell
<p>Actually, reading from the <a href="https://docs.craftcms.com/v2/templating/craft.request.html#methods" rel="noreferrer"><strong>Craft 2</strong> docs</a> it's:</p>

<pre><code>craft.request.getQueryString()      // returns the whole query string
craft.request.getQuery('success')   // returns only the value of 'success'
</code></pre>

CC BY-SA 4.0
2019-01-20T06:12:11.763Z
Thank you, Antoine, that was helpful. And in Craft 3 it seems to now be `craft.app.request.getQueryParam()` otherwise a deprecation error.
kr37
CC BY-SA 4.0
2019-01-22T02:19:04.217Z
@kr37 Cool! I suggest you turn your comment into a standalone answer, that would be helpful for Craft 3 users. I updated my answer to indicate that it applies to Craft 2.
antoine
CC BY-SA 4.0
2019-01-19T00:56:22.307Z
2019-01-22T02:17:44.017Z
2019-01-22T02:17:44.017Z
antoine
<p>As @kr37 pointed out in the comments to another answer, the method for Craft 3, and now 4, is <a href="https://web.archive.org/web/20220518223359/https://docs.craftcms.com/api/v4/craft-web-request.html#method-getqueryparam" rel="nofollow noreferrer"><code>craft.app.request.getQueryParam()</code></a></p>
<pre><code>{# get $_GET['foo'], if it exists #}
{% set foo = craft.app.request.getQueryParam('foo') %}

{# get $_GET['foo']['bar'], if it exists #}
{% set bar = craft.app.request.getQueryParam('foo.bar') %}
</code></pre>

CC BY-SA 4.0
2022-11-03T14:44:16.830Z
2022-11-03T14:44:16.830Z
Jacob
<p>I wrote a PHP script to deploy data to live-cdn and included a "deploy" button on the dashboard. the script returns ?success=true, and i need to show div element with "Congratulations"</p>

<p>i tried this with no success:</p>

<pre><code>{% if app.request.query.get('success') %}
  &lt;div&gt;
    Glückwunsch! Deployment läuft.
  &lt;/div&gt;
{% endif %}
</code></pre>

<templating>
How can I get parameters in twig?
# How can I get parameters in twig?

(Asked by: username_0 on 2016-03-31)

I wrote a PHP script to deploy data to live-cdn and included a "deploy" button on the dashboard. the script returns ?success=true, and i need to show div element with "Congratulations"
i tried this with no success:
{% if app.request.query.get('success') %}
  
    Glückwunsch! Deployment läuft.
  
{% endif %}

**Tags:** templating

---

## 3 answers

### Answer by username_1 on 2016-03-31. Score: 3 | Accepted answer

Use:
{% if craft.request.getQueryString('success') %}

https://craftcms.com/docs/templating/craft.request#getQueryString


---

### Answer by username_2 on 2019-01-19. Score: 11

Actually, reading from the Craft 2 docs it's:
craft.request.getQueryString()      // returns the whole query string
craft.request.getQuery('success')   // returns only the value of 'success'

> **Comments:**
> **username_3**: Thank you, Antoine, that was helpful. And in Craft 3 it seems to now be `craft.app.request.getQueryParam()` otherwise a deprecation error.  
> **username_2**: @kr37 Cool! I suggest you turn your comment into a standalone answer, that would be helpful for Craft 3 users. I updated my answer to indicate that it applies to Craft 2.  

---

### Answer by username_4 on 2022-11-03. Score: 3

As @kr37 pointed out in the comments to another answer, the method for Craft 3, and now 4, is craft.app.request.getQueryParam()
{# get $_GET['foo'], if it exists #}
{% set foo = craft.app.request.getQueryParam('foo') %}

{# get $_GET['foo']['bar'], if it exists #}
{% set bar = craft.app.request.getQueryParam('foo.bar') %}


---

