简体   繁体   English

告诉TYPO3扩展使用Typoscript使用不同的模板

[英]Tell TYPO3 extension to use different template using Typoscript

I'm trying to get an extension/plugin on a page to use a different template from the one its hardcoded with. 我正在尝试在页面上获取扩展名/插件,以使用与其硬编码模板不同的模板。

I made an html template stored in: typo3conf/ext/myextension/pi1/new_extension_template.html 我制作了一个HTML模板,存储在:typo3conf / ext / myextension / pi1 / new_extension_template.html

I made a typoscript template object in the root of my site (so it would definitely get picked up). 我在网站的根目录中创建了一个Typoscript模板对象(因此肯定会被选中)。 In it, I have defined the following simple Typoscript (names changed for demonstration) 在其中,我定义了以下简单的Typoscript(名称已更改,用于演示)

plugin.tx_myextension_pi1 {
     templateFile = typo3conf/ext/myextension/pi1/new_extension_template.html
}

However when I load the page containing the plugin, I get a "no typoscript template found" error on that black TYPO3 error page. 但是,当我加载包含插件的页面时,在该黑色TYPO3错误页面上收到“找不到打字模板”错误。

I have tried a bunch of alternative ways in case the syntax was wrong but the above worked for me when working with the tt_news plugin. 我尝试了多种替代方法,以防语法错误,但是在使用tt_news插件时,上述方法对我有用。

Eg I have tried these without success too: 例如,我也尝试了这些但没有成功:

templateFile.file = typo3conf/ext/myextension/pi1/new_extension_template.html
...
tempfile.template_file = typo3conf/ext/myextension/pi1/new_extension_template.html

Any ideas what I'm doing wrong? 有什么想法我做错了吗? Can html templates stored in typo3conf be called via typoscript stored outside the plugin? 可以通过插件外部存储的错字来调用typo3conf中存储的html模板吗?

I'm thinking perhaps html template files would have to be stored in fileadmin/plugin_templates/ for this to work. 我在想,也许html模板文件必须存储在fileadmin / plugin_templates /中才能起作用。

You are mixing things: no typoscript template found means that on the page you inserted the plugin there is no TS template available. 您正在混淆: no typoscript template found ,这意味着在您插入插件的页面上没有可用的TS模板。

Page with plugin isn't nested under the main page (which - as I assume - has main TS template and is displayed properly), so just drag it into the main page, or create new TS template on its level. 带插件的页面没有嵌套在主页下(我假设它具有主TS template并正确显示),因此只需将其拖动到主页中,或在其级别上创建新的TS模板。

您可以使用模板模块进行检查

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

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