简体   繁体   English

覆盖 TYPO3 模板

[英]Override TYPO3 templates

I have a TYPO3 website that is built on a sitepackage that extends bootstrap_package.我有一个 TYPO3 网站,该网站建立在扩展 bootstrap_package 的网站包上。 I need to add more templates and design changes to the sitepackage, so I created a new extension.我需要向站点包添加更多模板和设计更改,因此我创建了一个新的扩展。 When I want to override the templates from sitepackage with the templates from my new extension, they all get overridden, and I get errors on the pages that used templates from the sitepackage.当我想用我的新扩展中的模板覆盖站点包中的模板时,它们都会被覆盖,并且我在使用站点包中的模板的页面上出现错误。 Is there a way to load all templates, from the initial bootstrap_package, my sitepackage, and the new extension?有没有办法加载所有模板,从初始 bootstrap_package、我的站点包和新扩展?

This is from the constants.txt of the sitepackage (example_theme), where it extends bootstrap_package:这是来自 sitepackage (example_theme) 的 constants.txt,它扩展了 bootstrap_package:
constants.txt of the sitepackage example_theme ,站点包 example_theme 的 constants.txt 站点包 example_theme 的 constants.txt

and this is how I am trying to override it with my new extension: constants.typoscript of my new extension这就是我试图用我的新扩展覆盖它的方式: constants.typoscript of my new extension 我的新扩展的 constants.typoscript and setup.txt of the sitepackage example_theme站点包 example_theme 的 setup.txt 站点包 example_theme 的 setup.txt

If I do this, then in the backend I can see that example_theme is not loaded:如果我这样做,那么在后端我可以看到 example_theme 没有加载:
backend setup后端设置后端设置

The pages that used templates from the sitepackage example_theme give me this error:使用 sitepackage example_theme 模板的页面给我这个错误:
error on pages that use templates from example_theme使用 example_theme 模板的页面出现错误使用 example_theme 模板的页面出现错误

Either you have the wrong loading order of the extensions, or there is an extension not loaded.您的扩展加载顺序错误,或者未加载扩展。

Especially if you use only constants to define the paths you will miss a definition as only one constant (per path) is inserted.特别是如果你只使用常量来定义路径,你会错过一个定义,因为只插入一个常量(每个路径)。

In your case you should not use constants in your extension new_extension but set the value 2 in the setup immediately.在您的情况下,您不应在扩展new_extension中使用常量,而应立即在设置中设置值2

page {
  10 {
    TemplateRootPaths.2 = EXT:new_extension\Resources\Private\Templates\Page\
    PartialRootPaths.2 = EXT:new_extension\Resources\Private\Partials\Page\
    LayoutRootPaths.2 = EXT:new_extension\Resources\Private\Layouts\Page\
  }
}

in this way you should end up with 3 values for each path.这样,您应该为每个路径得到 3 个值。
(example just for templates:) (仅针对模板的示例:)

:
[templateRootPaths]
   [0] = EXT:bootstrap_package\Resources\Private\Templates\Page\
   [1] = EXT:example_theme\Resources\Private\Templates\Page\
   [2] = EXT:new_extension\Resources\Private\Templates\Page\  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM