如何在 TYPO3 中使用 sitepackage 的模板覆盖
bootstrap_package
模板?我在我的站点包中尝试了这段代码setup.typoscript
。
plugin.tx_bootstrap_package {
view {
templateRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Templates/
1 = EXT:fileadmin/templates/ext/bootstrap_package/Templates/
}
partialRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Partials/
1 = fileadmin/templates/ext/bootstrap_package/Partials/
}
layoutRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Layouts/
1 = fileadmin/templates/ext/bootstrap_package/Layouts/
}
}
}
这种问题可以通过查看页面当前的 TypoScript 来识别。
使用后端的
Template
模块,选择一个页面,然后使用 TSOB (TypoScript-Object-Browser
)(在工作区域顶部的下拉列表中选择)
在这里您可以选择一些配置:
Constants
/Setup
:设置是工作配置,但constants
可能会为setup
准备一些数据。
我的喜好:
[x] Display comments
[x] Sort alphabetically
Display Constants [Substituted constants in green V]
您可能还需要切换各个页面的条件。
然后您可以看到活动的 TypoScript。在这里你可以发现没有你设置的结构。
在
Constants
中,您有以下值:
plugin.bootstrap_package {
view {
templateRootPath = EXT:bootstrap_package/Resources/Private/Templates/
partialRootPath = EXT:bootstrap_package/Resources/Private/Partials/
layoutRootPaths = EXT:bootstrap_package/Resources/Private/Layouts/
}
}
这些常量仅用于:
plugin.tx_seo {
view {
templateRootPaths {
20 = EXT:bootstrap_package/Resources/Private/Templates/Seo/
21 = {$plugin.bootstrap_package.view.templateRootPath}Seo/
}
partialRootPaths {
20 = EXT:bootstrap_package/Resources/Private/Partials/Seo/
21 = {$plugin.bootstrap_package.view.partialRootPath}Seo/
}
layoutRootPaths {
20 = EXT:bootstrap_package/Resources/Private/Layouts/Seo/
21 = {$plugin.bootstrap_package.view.layoutRootPath}Seo/
}
}
}
在
Setup
中使用这些常量:
page {
10 {
templateRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Templates/Page/
1 = {$page.fluidtemplate.templateRootPath}
}
partialRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Partials/Page/
1 = {$page.fluidtemplate.partialRootPath}
}
layoutRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Layouts/Page/
1 = {$page.fluidtemplate.layoutRootPath}
}
}
}
(正如朱利安已经写的那样。)
如果你替换这些常量,它可能看起来像:
page {
10 {
templateRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Templates/Page/
1 = EXT:site_extension/Resources/Private/Templates/Page/
}
partialRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Partials/Page/
1 = EXT:site_extension/Resources/Private/Partials/Page/
}
layoutRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Layouts/Page/
1 = EXT:site_extension/Resources/Private/Layouts/Page/
}
}
}
如果您有更多路径,您可以插入其他值,这些值将按自上而下的顺序检查是否有匹配的 FLUID 模板。
引导程序包中还有其他模板路径,但这些路径与 CE(内容元素)相关并使用其他常量:
lib.contentElement {
templateRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Templates/ContentElements/
10 = {$plugin.bootstrap_package_contentelements.view.templateRootPath}
}
partialRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Partials/ContentElements/
10 = {$plugin.bootstrap_package_contentelements.view.partialRootPath}
}
layoutRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Layouts/ContentElements/
10 = {$plugin.bootstrap_package_contentelements.view.layoutRootPath}
}
}
您可以通过常量轻松设置附加的(布局|模板|部分)RootPath: 配置 > TypoScript > page.fluidtemplate
Bootstrap 包不是普通的 Extbase 插件。相反,它直接在全局级别上配置 TypoScript。所以例如
page = PAGE
- 或 FLUIDTEMPLATE
的路径(第 103 行)
page {
10 {
templateRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Templates/Page/
1 = {$page.fluidtemplate.templateRootPath}
}
partialRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Partials/Page/
1 = {$page.fluidtemplate.partialRootPath}
}
layoutRootPaths {
0 = EXT:bootstrap_package/Resources/Private/Layouts/Page/
1 = {$page.fluidtemplate.layoutRootPath}
}
}
}
我需要在Typo3的页眉和页脚中插入政府代码,但我无法确定它是否在默认模板上或者是否在常量中完成,有人可以帮助我吗?