dongxiaoke2018 2017-04-05 11:49
浏览 37
已采纳

在两个或多个模块的视图之间执行合并

I have a Phalcon PHP modular application. I am making an administrative interface to control which modules should be used in the system. One module controls the application's default interface, while the other modules add functionalities.

I have the problem: when another module to enabled, it can add the HTML content to the other interface control module. In this way I would like to merge two or more views. I am using Volt as template engine.

Is this possible in Phalcon?

  • 写回答

1条回答 默认 最新

  • duanpi2033 2017-04-10 15:27
    关注

    Note: This was asked on the official Phalcon forums. I answered it over there and it got accepted. I am just mirroring my answer so future readers can get an answer here without being redirected from StackOverflow. Phalcon forum mirror: https://forum.phalconphp.com/discussion/15891/perform-merge-between-views-of-two-or-more-modules


    config.php

    You will need to define your modules in the app/config/config.php file like so;

    return new \Phalcon\Config([
    // ...
        'modules' => [
            'module01',
            'module02',
            ...
            'moduleN',
        ],
    // ...
    ]);
    

    *Controller.php

    Then, in your controller, you'd set a view property to store the active modules like so;

    $this->view->modules_enabled = $this->di->get("config")->modules;
    

    *.volt

    And finally in your volt file, just check the module is in the array holding active modules, and if so, display the view using partials.

    {% if module01 in modules_enabled %}
       <div id="module">{{ partial("partials/module01") }}</div>
    {% endif %}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么