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

Problema inheritance Volt

I have created a volt inheritance, but doesn't work

/views/index.volt
<!DOCTYPE html>
<html>
    <head>
        {% block head %}
        {% endblock %}
    </head>

    <body>
      {% block content %}
      {% endblock %}
    </body>
</html>

/views/index/index.volt
{% extends "index.volt" %}

{% block head %}
  <title>Page Title</title>
{% endblock %}

{% block content %}
  <h1>Page Child</h1>
  text
{% endblock %}

This displays


<!DOCTYPE html>
<html>
    <head>

    </head>

    <body>

    </body>
</html>

What is wrong?



58.4k
Accepted
answer

Hi

You try disable main layout

$view->disableLevel([View::LEVEL_MAIN_LAYOUT => true, View::LEVEL_LAYOUT => true]);

See more https://github.com/phanbook/phanbook/blob/master/core/config/services.php#L173

Works perfectly, thanks ;)

Hi

You try disable main layout

$view->disableLevel([View::LEVEL_MAIN_LAYOUT => true, View::LEVEL_LAYOUT => true]);

See more https://github.com/phanbook/phanbook/blob/master/core/config/services.php#L173