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

Volt - Include assign vars

Is there a usual way to assign variables specially for the template using "include"?

{% include "path/to/template.volt" %}

I think if you are using {% include %} most of the time you include a partial template (let's say a variable x is included) into the main template and then $this->view->setVar("x", what you define as x ) in your main controller.



77.7k
Accepted
answer
edited Aug '15

https://docs.phalcon.io/en/latest/reference/volt.html#view-integration

{# Passing extra variables #}
<div id="footer">{% include "partials/footer" with ['links': links] %}</div>


7.0k
edited Aug '15

Well, thank you Lajos Bencz. :)
BTW.: Sorry for the bad vote.. my mistake x)