【问题标题】:Symfony: append YAML settings instead of overrideSymfony:附加 YAML 设置而不是覆盖
【发布时间】:2011-12-17 02:47:48
【问题描述】:

在 symfony 的 view.yml 中我可以这样设置样式表:

(in frontend/config/view.yml)

stylesheets: [main, second]

如果我想将样式表添加到特定模块,而不更改默认模块,该怎么办?所以不要写这一行:

(in frontend/modules/mymodule/config/view.yml)

stylesheets: [main, second, third]

我可以这样写:

(in frontend/modules/mymodule/config/view.yml)

stylesheets: [..., third]

这样我可以更改所有模块的默认样式表,而不必一一更改。

那么,有可能吗?

【问题讨论】:

    标签: view symfony1 settings yaml


    【解决方案1】:

    没有。它将覆盖存储在应用级别的stylesheets 定义。

    但您可以执行以下操作之一:

    • 将样式表添加到特定模板 - 将以下内容添加到您的模板文件中:

      <?php use_stylesheet('third') ?>
      
    • 将样式表添加到模块的所有模板 - 将以下内容添加到您的 actions.class.php

      public function preExecute()
      {
        parent::preExecute();
        $this->getResponse()->addStylesheet('third');
      }
      

    【讨论】:

      【解决方案2】:

      您应该在模块的 view.yml 中使用 «all» 而不是 «default»,否则它将覆盖应用程序中定义的默认视图配置。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-07-01
        • 1970-01-01
        • 1970-01-01
        • 2015-05-25
        • 1970-01-01
        • 2015-09-11
        • 2013-02-09
        • 2018-09-15
        相关资源
        最近更新 更多