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

Variables in .phtml files

Hi, I tried to pass variables from my controller (.php file) to my view (.phtml file). But in my .phtml file, "{{ varxx }}" is not evaluate : my browser just display "{{ varxx }}" So I tried "{# Comment #}" for a comment, which is displayed "{# Comment #}". Direct loading of .phtml file from my browser : same pb. Seem to be not a Phalcon pb :).

No really good solutions found on the Web, but not a lot of responses...

So my questions : is it working on your websites, do you use that technical solution, or is it simply obsolete and a no more used solution ? Or is it another pb of compatibility with my config ?

Thank's



5.3k
Accepted
answer

the sintaxe you are using is for .volt files

https://docs.phalcon.io/en/3.2/volt



1.5k

Ok, I try .volt files. Thank's for your help. Phalcon is not easy. I'm not sure only .volt. See in your link, in "Basic Usage" :

{# app/views/posts/show.phtml #} <!DOCTYPE html> <html> <head> <title>{{ title }} - An example blog</title> </head> <body>

    {% if show_navigation %}
        <ul id='navigation'>
            {% for item in menu %}


1.5k

As said in the manual : "As with other templating engines, you may register Volt in the view component, using a new extension or reusing the standard .phtml". .volt or .phtml is not important, you just have to start engine. I tried : both work fine. Thank's to David.