【问题标题】:Overload dashboard template not working - SilverStripe 3.3重载仪表板模板不起作用 - SilverStripe 3.3
【发布时间】:2016-02-15 18:36:45
【问题描述】:

我正在使用 Unclecheese 仪表板模块。现在我正在尝试重载(? I think that's the right englisch term) Dashboard_Content.ss 模板。为此,我将其内容复制到模块目录下“包含”文件夹中的同名新文件中。进行更改并保存。

刷新后没有任何反应,但是如果我将相同的模板文件放在 mysite/templates/Includes 而不是 mymodule/templates/Includes 下,它会按预期工作......

即使我从仪表板文件夹中删除原始模板文件,我的模块文件夹中的文件也无法识别。

我的下一个尝试是扩展仪表板并使用另一个模板进行渲染

<?php
class CSYMDashboardExtension extends DataExtension {

  public function init() {
    $config = SiteConfig::current_site_config();
    if(!$config->CompanyID || !$config->CompanyOwner || !$config->Bank || !$config->IBAN || !$config->BIC || !$config->UstID || !$config->SenderEmail) {
      return $this->owner
        ->customise(
          ['Message' => 'Die Einrichtung ist noch nicht komplett abgeschlossen! Wird das System in diesem Zustand verwendet werden Fehler auftreten! Bitte setzen Sie die Einrichtung hier fort <a href="/admin/settings/">Einstellungen</a>']
        )->renderWith(['DCTest']);
    }
  }
}

但这不起作用,无论模板文件位于何处(我也尝试过onAfterInit()

在我的模块 config.yml 中,我声明它在框架和 cms After: 'framework/*','cms/*' 之后加载

有人有解决这个问题的办法吗?

编辑: 附带说明一下,我在重载 UploadField_FileButtons.ss 模板时遇到了类似的问题。在我将“包含”文件夹更改为“包含”之前,这也未被识别。但是对于仪表板案例,它不能双向工作。

【问题讨论】:

    标签: silverstripe


    【解决方案1】:

    一个模块模板将难以覆盖另一个模块的模板(如果可能的话..?)

    我建议您覆盖特定于主题模块的 &lt;current_theme&gt;_dashboard 文件夹中的模板,并使其具有与您目前所拥有的结构相似的结构。

    所以最后,您的文件将位于: themes/templates/&lt;current_theme&gt;_dashboard/includes/Dashboard_Content.ss

    参考: https://docs.silverstripe.org/en/3.2/developer_guides/templates/template_inheritance

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-02
      • 2019-05-09
      • 2019-11-18
      • 1970-01-01
      • 1970-01-01
      • 2013-06-17
      • 2020-09-05
      相关资源
      最近更新 更多