1

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 %}
2

Use:

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

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

3

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'
  • 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 at 6:12
  • 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. – antoine Jan 22 at 2:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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