Views in many directories

I use some modules in which i want use views extending one template. This template in dir outside module/view dir. I cant extend this template nicely, bcs $view->setViewsDir can add only one dir.

I have to set view dir = dir with modules (which also include dir whit tempate), call $this->view->pick("clients/views/index"); in controllers and use {% extends core/views/base.twig %} in views.

How can I make it more nicely now? And can core developers add feature to pass in setViewsDir array whis dirs?



1.5k
edited Jul '14

I think you can not do it, with the base phalcon, but you can extend the view, and create a getCorePartial method, which do not use the base view dir.

There is a NFR about the multiple view dir: https://github.com/phalcon/cphalcon/issues/1698



1.5k

You can do something like this:

class MyView extends View {
function getCorePartial($file) {
    $viewDir = $this->getPartialsDir ();
    $this->setPartialsDir ('some dir, it can come from ur config');
    $this->partial($file);
    $this->setPartialsDir ($viewDir);
}
}