Hi,
I'm having a problem in a multi-module app, my views are being rendered but not my common layout. I want to have an anonymous layout, a frontend layout and a backend layout.
This is my bootstrap code for configuring the view with Volt support:
$this->di->set('view', function () use ($config) {
$view = new View();
$view->registerEngines(array(
'.volt' => '\Phalcon\Mvc\View\Engine\Volt',
'.phtml' => function ($view, $di) use ($config) {
$volt = new Volt($view, $di);
# voltCacheDir
$volt->setOptions(array(
'compiledPath' => PROJECT_PATH . $config->volt->cacheDir,
'compiledSeparator' => '_',
'compileAlways' => true));
return $volt;
}
));
return $view;
});
My application structure is as follows
apps/Project/Application/Signup/View/index/index.phtml apps/Project/Application/Shared/View/index/index.phtml apps/Project/Application/Campaign/View/index/index.phtml
apps/Project/Application/Shared/View/layouts/index.phtml
And my module configuration is here:
apps/Project/Application/Shared/Module.php --> index layout apps/Project/Application/Signup/Module.php --> anoynmous layout apps/Project/Application/Campaign/Module.php --> index or backend layout
I have the following code on every Module.php:
/**
* Registers the module-only services
*
* @param Phalcon\DI $di
*/
public function registerServices(DiInterface $di)
{
$view = $di->get('view');
$view->setViewsDir(__DIR__ . '/View/');
$view->setLayoutsDir(__DIR__ . '/View/layouts/');
$di->set('view', $view);
}
I've tried to setLayoutsDir directly in my action controller, also in the bootstrap but it doesn't works. Specifying the setLayout() method doesn't works neither. But If I do a getLayouts() it gives me the correct layout but it stills not rendered, so I don't understand what's happening here.
Moreover, I've tried to write my view directory in lowercase or in plural but nothing changes....I would appreciate any help.
thanks!