We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

if isset($_GET) using volt syntax

I am looping through an object in my View, and would like to recreate the following PHP code in Volt:

echo isset($_GET['param']) ? 'class="active"' : '';

How would I go about (a) getting this parameter with Volt, and (b) recreating that line of code with Volt syntax?

Current code:

{% for (item in object) %}
    <li>{{ link_to('index/browse/' ~ item.id, '<i class="fa fa-caret-right"></i>' ~ item.id) }}</li>
{% endfor %}

The Volt code will need to go between <li and >

edited Aug '16

Hey friend :)

{% if request.has('param') %}
    {{ request.get('param') }}
{% endif %}

Or the shorthand version:

 {{ request.has('param') ? "hello" : "not-defined" }}

Don't use $_GET anywhere. Just use request service as wrote above.