Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Question about volt template

project folder structure:

/app
  /controllers
    ServiceController.php
  /views
    /service
      about.volt
    index.volt
/public
  /css
  index.php
{# index.volt #}
<!DOCTYPE html>
<html>
    <head>
        {% block head %}{% endblock %}
    </head>
    <body>
{% block content %}{% endblock %}
    </body>
</html>
{# about.volt #}
{% block head %}<... head section here ...>{% endblock %}
{% block content %}<... simple html code here ...>{% endblock %}

but looks like it does not work, event if I add {% extends "index.volt" %} to about.volt. And when I change the 2 files like

{# index.volt #}
<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
{{ content() }}
    </body>
</html>
{# about.volt #}
<... head section here ...>
<... simple html code here ...>

the page can be shown on browser, but that is not what I want, any idea? thx.



1.1k
Accepted
answer
edited Mar '14

Hi @miao606, I also had this problem until yesterday.

In this forum issue I explain my solution Volt block not working with hierarchical view rendering

Try to remove {{ content() }} from the main template, add {% extends "index.volt" %} in the top of the about.volt file and set the view render level to LEVELACTIONVIEW (Ex.: $view->setRenderLevel(\Phalcon\Mvc\View::LEVELACTIONVIEW)).

After these changes, remove the volt render cache files to test that the main template changes works fine.

I hope it works for you.



17.0k

It works for me, thanks Tino.