How do I use “Main Layout” views in a multi module Phalcon application?

后端 未结 3 970
谎友^
谎友^ 2021-01-13 05:09

I am using a \"multi module\" MVC structure for my PhalconPHP application.

One issue I am trying to figure out is how I can configure my \"Main Layout\" view to be <

3条回答
  •  鱼传尺愫
    2021-01-13 05:38

    What you are looking for cannot be done at this version (0.5.0 stable) or the next one 0.6.0 (since it is frozen, pending release).

    In your module you register your views

    // /module1/Module.php
    
    // Registering the view component
    $di->set(
        'view', 
        function () {
            $view = new \Phalcon\Mvc\View();
            $view->setViewsDir('../apps/module1/views/');
            return $view;
        }
    );
    
    // /module2/Module.php
    
    // Registering the view component
    $di->set(
        'view', 
        function () {
            $view = new \Phalcon\Mvc\View();
            $view->setViewsDir('../apps/module2/views/');
            return $view;
        }
    );
    

    and so on.

    You can also have a master view that will be common for all modules, but not a combination of the two.

    //Registering a shared view component
    $di->set(
        'view', 
        function() {
        $view = new \Phalcon\Mvc\View();
        $view->setViewsDir('../apps/views/');
        return $view;
        }
    );
    

    See this example on Github.

    This could very well be a NFR for the 0.7 version.

提交回复
热议问题