Volt templates views and layouts dirs

What I am trying to achieve is to use be able to to use views dir from the current module, and set the layout from another. Ity seems that this is now possible in 2.1.x : https://github.com/phalcon/cphalcon/commit/276545f6ece8ac6583ff07afa674080b4ce57ac9 but for me it is not working.

Example:

FrontendModule Views layout.volt

DemoModule Views index index.volt (i need this file to extend layout.volt from FrontendModule)

I set the view service in DemoModule with this:

    $view->setViewsDir(PHAT_TO_VIEWS_FROM_DEMO_MODULE);
    $view->setLayoutsDir(PHAT_TO_LAYOUT_FROM FRONTEND_MODULE);

But, "extend" is searching for layout.volt in views dir, ignoring layouts dir.

Any ideas about how can I make this work ?

Phalcon 2.1.x (build today from 2.1.x branch)



772

What are values of defines?

PHAT_TO_VIEWS_FROM_DEMO_MODULE
PHAT_TO_LAYOUT_FROM FRONTEND_MODULE // You have a space this parameter, is It right?


35.2k

PHAT_TO_VIEWS_FROM_DEMO_MODULE and PHAT_TO_LAYOUT_FROM FRONTEND_MODULE are not some predefined values. I just write it like that. can also be: /path/to/views/from/demo/module



35.2k

If I develop a user module, I need to be able to create the CRUD views also. With the correct routing, from my Admin module, I should be able (i am in fact) to access the User module. The problem is with the views. In my User module, views/admin/ files are extending a layout.volt . I need to specify that the layout.volt resides in my Admin module.

What I need It's similar with what Symfony is doing - being able to create a bundle with views and render them from another bundle.



772

// view/index.php
<html>
    <head>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Phalcon PHP Framework</title>
        {{ this.assets.outputCss('style') }}
    </head>
</html>

// controllers/UserController.php
<?php

class UserController extends ControllerBase
{

    public function initialize(){
        $this->assets
            ->collection('style')
            ->addCss('css/style.css'); // here
    }
    public function indexAction()
    {

    }
}

<?php

// controllers/AdminController.php
class AdminController extends ControllerBase
{

    public function initialize(){
        $this->assets
            ->collection('style')
            ->addCss('css/style_admin.css'); // here
    }
    public function indexAction()
    {

    }
}