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

in volt,how to get $_GET etc data value?

url: https://host/controller/test/88

in volt template,how can i get 88?

must in controller use setVar()?

i seen the twig office document, catn't get the value direct



98.9k
Accepted
answer
edited Oct '14

You can get it from the dispatcher:

{{ dispatcher.getParam(0) }}

Or from the view component:

{% set params = view.getParams() %}
{{ params[0] }}

Or add a function to the Volt compiler that uses a fancy syntax:

$volt->getCompiler()->addFunction('get_param', function($arguments) {
    return '$this->dispatcher->getParam(' . $arguments . ')';
});

Then in your view:

{{ get_param(0) }}


17.8k

ok,thanx

but i don't like all of method above

i also use setVar in controller :)