Ok i just figured it out after some debugging.. cannot dump vars in view class which is a bit annoying ;)
My problem was indeed, that the layout needs to be relative to the view dir. When you override the view dir as on: https://stackoverflow.com/a/19941928/74651 it will look for the layout on the original view dir not the override.
It's possible to override this in _engineRender a bit annoying that they force the relative directory and only trigger and event if a file has been found not very flexible.
<?php
namespace Phapp\Mvc;
class View extends \Phalcon\Mvc\View {
/**
* @param array $engines
* @param string $viewPath
* @param boolean $silence
* @param boolean $mustClean
* @param \Phalcon\Cache\BackendInterface $cache
*/
protected function _engineRender($engines, $viewPath, $silence, $mustClean, $cache) {
// Layout override
if ($this->getCurrentRenderLevel() !== \Phalcon\Mvc\View::LEVEL_LAYOUT) {
return parent::_engineRender($engines, $viewPath, $silence, $mustClean, $cache);
}
foreach ($engines as $extension => $engine) {
if (!$engine instanceof View\Engine\ThemeInterface) {
continue;
}
$layout = $engine->getThemePath().$viewPath.$extension;
if (is_readable($layout)) {
$originalViewDir = $this->getViewsDir();
$this->setViewsDir($engine->getThemePath());
$content = parent::_engineRender($engines, $viewPath, $silence, $mustClean, $cache);
$this->setViewsDir($originalViewDir);
return $content;
}
}
}
}