通过 Typoscript 在 TYPO3 中添加模板导致异常
Add Template in TYPO3 via Typoscript leads to exception
尝试学习 TYPO3 我已经设置了一个新的(版本 8.7.6)安装。到目前为止,我一切顺利,但是当我尝试使用 Typoscript 为我的第一个也是唯一一个页面设置模板时,我在前端收到错误消息 "Uncaught TYPO3 Exception #1294587217: The page is not configured! [type=0][page]. This means that there is no TypoScript object of type PAGE with typeNum=0 configured" .
编辑-解决方案:
随着 NextThursday 的回答,我发现了我 打字错误 中的两个缺陷。所以基本上它与下面命名的任何细节都无关。
如回答中所述page.typeNum = 0
必须在page = PAGE
下方添加,这似乎是一个"new"概念,至少是不是的一部分我参考的解决方案
我的进一步页面定义的左括号“{”不允许在下一行中,但必须在同一行中,使两行 page
和 {
到单行page {
详情:
- 已删除,因为不是问题的一部分
错别字:
#Force cache refresh
config.cache_period = 2
# Default PAGE object:
/*
page = PAGE
page.10 = TEXT
page.10.value = HELLO WARLD!
*/
# My new PAGE object
page = PAGE
page
{
bodyTag = <body>
10 = TEMPLATE
10.template = FILE
10.template.file = fileadmin/templates/blog/small.html
10.workOnSubpart = BODYSTART
}
模板文件 small.html 位于文件夹 DOCUMENT_ROOT\mytypo3\fileadmin\templates\blog:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<!-- ###BODYSTART### begin -->
<!-- ###BODYSTART### end -->
</body>
</html>
我很乐意解释上面的代码有什么问题和如何正确设置模板下面的页面给定的 ("Details") 条件。
如错误所述,您的 TypoScript 缺少 typeNum:
page.typeNum = 0
如评论中所写,正确答案是大括号必须在同一行。正确的代码是
page = PAGE
page {
bodyTag = <body>
10 = TEMPLATE
10.template = FILE
10.template.file = fileadmin/templates/blog/small.html
10.workOnSubpart = BODYSTART
}
typeNum 设置为 0,请参阅 https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Page/Index.html#typenum
处的文档
This determines the typeId of the page. The &type= parameter in the URL determines, which page object will be rendered. The value defaults to 0 for the first found PAGE object, but it must be set and be unique as soon as you use more than one such object (watch this if you use frames on your page)
!
尝试学习 TYPO3 我已经设置了一个新的(版本 8.7.6)安装。到目前为止,我一切顺利,但是当我尝试使用 Typoscript 为我的第一个也是唯一一个页面设置模板时,我在前端收到错误消息 "Uncaught TYPO3 Exception #1294587217: The page is not configured! [type=0][page]. This means that there is no TypoScript object of type PAGE with typeNum=0 configured" .
编辑-解决方案:
随着 NextThursday 的回答,我发现了我 打字错误 中的两个缺陷。所以基本上它与下面命名的任何细节都无关。
如回答中所述
page.typeNum = 0
必须在page = PAGE
下方添加,这似乎是一个"new"概念,至少是不是的一部分我参考的解决方案我的进一步页面定义的左括号“{”不允许在下一行中,但必须在同一行中,使两行
page
和{
到单行page {
详情:
- 已删除,因为不是问题的一部分
错别字:
#Force cache refresh
config.cache_period = 2
# Default PAGE object:
/*
page = PAGE
page.10 = TEXT
page.10.value = HELLO WARLD!
*/
# My new PAGE object
page = PAGE
page
{
bodyTag = <body>
10 = TEMPLATE
10.template = FILE
10.template.file = fileadmin/templates/blog/small.html
10.workOnSubpart = BODYSTART
}
模板文件 small.html 位于文件夹 DOCUMENT_ROOT\mytypo3\fileadmin\templates\blog:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<!-- ###BODYSTART### begin -->
<!-- ###BODYSTART### end -->
</body>
</html>
我很乐意解释上面的代码有什么问题和如何正确设置模板下面的页面给定的 ("Details") 条件。
如错误所述,您的 TypoScript 缺少 typeNum:
page.typeNum = 0
如评论中所写,正确答案是大括号必须在同一行。正确的代码是
page = PAGE
page {
bodyTag = <body>
10 = TEMPLATE
10.template = FILE
10.template.file = fileadmin/templates/blog/small.html
10.workOnSubpart = BODYSTART
}
typeNum 设置为 0,请参阅 https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Page/Index.html#typenum
处的文档This determines the typeId of the page. The &type= parameter in the URL determines, which page object will be rendered. The value defaults to 0 for the first found PAGE object, but it must be set and be unique as soon as you use more than one such object (watch this if you use frames on your page)
!