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

Multi module views with common layout

I know this has been asked before but to be honest I don't like any of the answers :) I have searched docs, forum and google.

I have a number of modules and one common directory. The common directory contains config, base controller, layout views. Each module contains it's own views. I want to use the common layout views accross the modules. How is this done?

I have taken a look at this - https://github.com/phalcon/mvc/tree/master/multiple-shared-layouts and have done something like this in my Module.php

 $di['view'] = function() {
        $view = new \Phalcon\Mvc\View();

        $view->setViewsDir(__DIR__ . '/views/');
        $view->setLayoutsDir('../../common/layouts/');
        $view->setTemplateAfter('main');

        return $view;
    };

This however gives me an error saying that /path/to/view/../../common/layouts/layout.phtml can't be found.

There must surely be a straight forward way of doing this with out breaking module conventions and stuffing module and layout views into the common directory?

Can't you use a symlink?