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.

Hierarchy view Question

Well I’m studying about hierarchy view and I don’t understand why I must put a file in /view/layouts/ for each controller.

I don’t understand well, but I think the execute order is:

1-. controller /view/layouts/users.volt (this have only content )

2-. Template (if exist) /view/layouts/admin.volt // I use this template to re-use the admin panel.

3-. Action /view/users/index

4-. main (/view/index)

Now the examples INVO and VOKURO have not this files and working so well, what is the difference?



30.7k
Accepted
answer
edited May '15

Hi,

the default behavior of view rendering hierarchy of a phalcon MVC application is explained here.

So far I can see, Invo use this default rendering system. Vokuro use a main views/index.volt and two templates in views/layouts : public.volt and private.volt.

// in PermissionsController.php line 18 in indexAction()
$this->view->setTemplateBefore('private');

// in IndexController line 16 in indexAction()
$this->view->setTemplateBefore('public');

If template apply to all controller actions, you may put the code above in initialize() method (or use default controller layout file, eg layouts/permissions.volt). If many controllers should use the same layout, they can extend from (in vokuro context) a PrivateController wich initialize the template.



9.5k

but to create the privatecontroller others inherit from him?



30.7k
// PrivateController

class PrivateController extends BaseController {....}

// PermissionsController

class PermissionsController extends PrivateController{...}


9.5k

thank's... you solved my question