4

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') %}
  <div>
    Glückwunsch! Deployment läuft.
  </div>
{% endif %}
3

Use:

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

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

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'
2
  • 4
    Thank you, Antoine, that was helpful. And in Craft 3 it seems to now be craft.app.request.getQueryParam() otherwise a deprecation error.
    – kr37
    Jan 20 '19 at 6:12
  • 4
    @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
    Jan 22 '19 at 2:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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