typo3 - FLUIDTEMPLATE 节 ... 不存在
问题描述
我正在使用 TYPO3 9.5.20
我尝试测试 FLUIDTEMPLATE 实现,我得到了一个Oops, ...
with Section "PageHeader" does not exist
.
这是我的模板文件:
<f:layout name="Layout1ColumnPage" />
<f:section name="WholeContent">
<div id="whole-content">
<f:format.raw>{contentNormal}</f:format.raw>
<f:format.raw>{contentLeft}</f:format.raw>
<f:format.raw>{contentRight}</f:format.raw>
</div>
</f:section>
<f:section name="MainContent">
<div id="main-content">
<f:format.raw>{contentLeft}</f:format.raw>
</div>
</f:section>
<f:section name="SideContent">
<div id="side-content">
<f:format.raw>{contentRight}</f:format.raw>
</div>
</f:section>
<f:section name="PageHeader">
<div id="page-header">
<div class = "body" cellpadding="0" cellspacing="0">
<div class = "header w200">
<div class = "headTD">
<f:image src = "fileadmin/Page/Resources/Public/Images/Country-Radio-2020.jpg" alt="HeaderImage" />
</div>
</div>
--- Ende Image ---
</div>
</div>
</f:section>
<f:section name="PageFooter">
<div id="page-footer">
<div id="footer-notice"> <p>This is the page footer area.</p> </div>
</div>
</f:section>
这是我的布局文件
<div id="page">
<f:render section="PageHeader" />
<div id="page-body">
<div id="page-title">{data.title}</div>
<f:render section="WholeContent" />
<div id="page-body-end"> </div>
</div>
<f:render section="PageFooter" />
</div>
这是我的设置文件:
page = PAGE
page.typeNum = 0
page.10 = FLUIDTEMPLATE
page.10 {
format = html
# Pfad zu der HTML Vorlage der Webseite
// file = fileadmin/Page/Resources/Private/Templates/CRtemplate.html
templateName = CRtemplate
# Pfad zu eingebundenen Partials
partialRootPaths.1 = fileadmin/Page/Resources/Private/Partials/
# Pfad zur Layout Datei
layoutRootPaths.1 = fileadmin/Page/Resources/Private/Layouts/
# Pfad zur Layout Datei
templateRootPaths.1 = fileadmin/Page/Resources/Private/Templates/
file.cObject = CASE
file.cObject {
key {
data = levelfield: -1, backend_layout_next_level, slide
override.field = TSFE:page|backend_layout
}
# Einbindung des ersten HTML Templates
1 = TEXT
1.value = fileadmin/Page/Resources/Private/Layouts/Layout1ColumnPage.html
# Einbindung des zweiten HTML Templates
2 = TEXT
2.value = fileadmin/Page/Resources/Private/Layouts/Layout2ColumnPage.html
}
variables {
# Verknüpfung der Inhalte mit dem Backend Layout
contentNormal < styles.content.get
contentNormal.select.where = colPos = 10
contentLeft < styles.content.get
contentLeft.select.where = colPos = 11
contentRight < styles.content.get
contentRight.select.where = colPos = 12
}
}
在我看来,部分的定义是正确的。如果我在布局文件渲染中删除,PageHeader
那么我会收到他找不到部分的消息WholeContent
。所以这似乎是一个普遍的问题。
编辑
正如下面 Bernd 提到的,在 Typo3 9.5.20 中,rootPath 的设置只能作为一个区域。例子
templateRootPaths.1 = fileadmin/Page/Resources/Private/Templates/
但是 9.5 文档仍然说,两者都是可能的!
还编辑了上面的代码!
解决方案
我无法确定是否有错误,但您可能会为模板考虑一些方面:
- 您的模板缺少带有命名空间声明的标题,例如
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:n="http://typo3.org/ns/GeorgRinger/News/ViewHelpers"
data-namespace-typo3-fluid="true">
:
</html>
- 您只定义一个路径。这在流体开始时很常见,并被路径数组所取代。(我不知道这是否仍然适用于单路径声明)
# Pfad zur Layout Datei
templateRootPaths.1 = fileadmin/Page/Resources/Private/Templates/
# Pfad zu eingebundenen Partials
partialRootPaths.1 = fileadmin/Page/Resources/Private/Partials/
# Pfad zur Layout Datei
layoutRootPaths.1 = fileadmin/Page/Resources/Private/Layouts/
- 你的模板声明很奇怪:
file
首先你通过评论避免声明- 然后你定义一个模板
templateName
- 除此之外
file.cObject
,您还错过了可能在 pageTS 中声明的后端布局,并且不再只是数字(在 中没有默认值case
)
同时,您可以使用核心定义的打字稿数据进行评估backend_layout
,从而产生简单的声明:backend_layout_next_level
pagelayout
page.10 {
templateName {
data = pagelayout
ifEmpty = default
}
}
您可以添加一个特殊的流体变量来调试backend_layout
字段中的值:
page.10 {
variables {
pagelayout = TEXT
pagelayout.data = pagelayout
}
}
小话题:
- 不要将模板存储在
fileadmin/
. 使用网站扩展。 {variable->f:format.raw()}
比<f:format.raw>{variable}</f:format.raw>
推荐阅读
- r - 将行名分配给数据框
- html - 两列的高度和宽度不同(引导程序)
- git - 从 git 存储库的历史记录中删除所有 .txt 文件
- http - 发送请求时:错误请求
- powershell - Powershell Import-Module SqlServer 和 SQLPS 不相处
- python - 我正在尝试从电报频道获取消息,但是当我运行此代码时,我得到了奇怪的输出
- java - 为什么我的字体在 java(eclipse) 的字体属性中不可见?
- google-cloud-platform - Terraform 为服务帐户设置 IAM 策略时抛出错误...需要权限 iam.serviceAccounts.setIamPolicy
- docker - Imagemagick yasm 奇点构建失败
- sql-server - 查询内存表