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

Setting up a multi module app with a common main layout

Hi,

I'm having some problems while trying to setup a multi module app with a common main layout.

Imagine I've three modules: backend, module1 and module2. I want to be able to use a common main layout for module1 and module2 and a specific layout for the backend module.

For each module1 and module2, in Module.php I register the view component like this:

$di->set('view', function() {
    $view = new \Phalcon\Mvc\View();
    $view->setLayoutsDir('../app/layouts/');
    return $view;
});

Now, how should folders and files be organized on the '../app/layouts' folder? The module1 and module2 controllers are not loading any views nor layouts from the layouts folder.

Can you help me solving this? Thank you.



98.9k

Hi Hugo, this is a sample skeleton for a multi-module application with a common layout: https://github.com/phalcon/mvc/tree/master/multiple-shared-layouts

Thank you very much! It worked as a charm! :)