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.

It does not display data from a child template

Hi all!

admin/index.volt content:

{% extends 'layouts/admin.volt' %}

{% block content %}

index admin text

{% endblock %}

layouts/admin.volt content:

<!doctype html> <html lang="ru"> <head> <meta charset="UTF-8"> <title>Admin dashboard</title> </head> <body> <h1>AdminDashboard</h1>

{% block content %}{% endblock %}

</body> </html>

tell me why not displayed the text "index admin text"?

site.com/admin/index compiled at:

<!doctype html> <html lang="ru"> <head> <meta charset="UTF-8"> <title>Admin dashboard</title> </head> <body> <h1>AdminDashboard</h1> </body> </html>

(without children block content)

Thanks, and sorry for my english dialect, i'm from other country.



6.2k
Accepted
answer

Hi, it seems like bug, i had try that, and i've got same issue, block doesn't work in other template, maybe this is fixed in 2.0.

I just installed 2.0 :) thanks for the reply.

Has it worked after installing?

No, this problem initially been

Hi,

i have no problems with using block in .volt templates. Are you sure you call rendering admin/index.volt? It looks like phalcon render just layouts/admin.volt.

I thing, if you comment first line in admin/index.volt, you got same result.

i have it directories structure for a views:

AdminController.php :

layouts/admin.volt :

admin/index.volt :

output "AdminDashboard" only, without "admin index page".

But(!) IndexController outputing normal (via extends layouts/main.volt) index/index.volt

I hope you understand me :)

Try out the following;

Put this line in the index action of the Admin controller

     $this->view->setLayout('admin');

And when you want to display any file from the block directory

<?php $this->view->partial('blocks/filename'); ?>

saved me to add lines to the file /app/index.php

$view->setLayoutsDir('../app/views/layouts');

and everything worked as it should.

but still I think it is a bit illogical because from Falcon know that this is not an ordinary layout pattern. Perhaps this is a matter of habit, I used to work with Twig.

Thank you guys for your help!