We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Volt - How to multiple inheritance

Hi please help i cant make it work.

I wanna do something like this :

  • A main layout file
  • A main "admin" layout file which inherit the main layout file, with the bonus some admin css and js file
  • A simple action file like admin/login admin/dashboard which extend admin layout

I have views/index.volt as main layout :

{% block header_css %}{% endblock %}
{% block content %}*text 1*{% endblock %}

I have views/layouts/admin.volt as admin layout

{% extends "index.volt" %}
{% block header_css %} new css {% endblock %}

{% block content %}* text 2* {% endblock %}

I have views/admin/login.volt as action file

{% extends "layouts/admin.volt" %}
{% block content %} *text 3 *{% endblock %}

And my controller :

public function loginAction(){

And what i see in browser is content of admin.volt which is text 2 not text 3 is what i want

edited Sep '17

The extender function not work with more then one level. I strongly recommend you make use of partial inclusions, especially in external files type js and css rather than try to do so many extends. It will keep your code clean and easy to repair.