在TYPO3后端,在Web - > Template Section中,在模板的Setup文本条目中,我想使用include a typoscript语法来@import
。
我在typo3
文件夹中设置了我的本地Typo3 v9.5.5测试实例(Windows),该文件夹本身位于htdocs
文件夹中(它是XAMPP安装)。所以后端的网址是http://localhost/typo3/typo3/index.php
,注意typo3
的重复。原因是,我在htdocs文件夹中设置了几个CMS,每个CMS都在一个具有相应名称的文件夹中。
我在哪里将脚本放在typo3文件夹中,包含它的正确代码行是什么?
我尝试了所有类型的路径,比如@import 'EXT:typo3testsite/TypoScript/playaround.typoscript'
,并将脚本放在htdocs/typo3/TypoScript/playaround.typoscript
或htdocs/typo3/typo3conf/sites/typo3testsite/TypoScript/playaround.typoscript
下,但没有成功。
在Site Managment - > Sites下设置的站点ID是typo3testsite
。
目前,脚本内容是
page = PAGE
page.10 = TEXT
page.10.value = Hello World
当我从父模板中清除常量和设置后,我得到服务不可用(503)。当我将代码直接放入Setup条目时,它会在首页上正确显示“Hello World”。
你可以这样做
# Import a single file
@import 'EXT:myproject/Configuration/TypoScript/randomfile.typoscript'
# Import multiple files in a single directory, sorted by file name
@import 'EXT:myproject/Configuration/TypoScript/*.typoscript'
# Import all files in a directory
@import 'EXT:myproject/Configuration/TypoScript/'
# It's possible to omit the file ending, then "typoscript" is automatically added
@import 'EXT:myproject/Configuration/TypoScript/'
见New syntax for importing TypoScript files
当您拥有自己的扩展时,该示例很有用。 'myproject'就是你的扩展名。 'EXT:'之后是扩展程序中配置文件的路径。
如果您从未构建过自己的扩展:Developing TYPO3 Extensions with Extbase and Fluid
通常,您可以将TypoScript文件存储在自定义扩展中; http://localhost/typo3/typo3conf/ext/customTemplates/Configuration/TypoScript/Setup.ts
(你可以给“customTemplates”任意你喜欢的名字)
然后你可以在TYPO3后端包含它,如下所示:
<INCLUDE_TYPOSCRIPT: source="FILE:typo3conf/ext/customTemplates/Configuration/TypoScript/Setup.ts">
__
编辑:从TYPO3 v9.0开始,有一个简化的import语句。以下内容来自TYPO3 Changelog文档。 https://docs.typo3.org/typo3cms/extensions/core/Changelog/9.0/Feature-82812-NewSyntaxForImportingTypoScriptFiles.html
# Import a single file
@import 'EXT:myproject/Configuration/TypoScript/randomfile.typoscript'
# Import multiple files in a single directory, sorted by file name
@import 'EXT:myproject/Configuration/TypoScript/*.typoscript'
# Import all files in a directory
@import 'EXT:myproject/Configuration/TypoScript/'
# It's possible to omit the file ending, then "typoscript" is automatically added
@import 'EXT:myproject/Configuration/TypoScript/'