如何在我的输入法中设置tx_news特定条件?
问题描述:
显示新闻从来就做出不同的模板布局来选择后端的编辑,我theme's配置PageTSconfig:如何在我的输入法中设置tx_news特定条件?
tx_news.templateLayouts {
10 = LLL:EXT:mytheme/Resources/Private/Language/locallang.xlf:news.layout.withoutDate
20 = LLL:EXT:mytheme/Resources/Private/Language/locallang.xlf:news.layout.highlightListView
30 = LLL:EXT:mytheme/Resources/Private/Language/locallang.xlf:news.layout.imageTeaserListView
}
在我的流体模板我可以切换条件像
<f:switch expression="{settings.templateLayout}">
<f:case value="10">
... use layout 1
</f:case>
<f:case value="20">
... use layout 2
</f:case>
<f:case value="30">
... use layout 3
</f:case>
</f:switch>
一切在这里工作得很好。
现在我想嵌入JavaScript的只有这些模板布局之一。 所以我试图在typoscript的条件中包含js,要求在此templateLayout设置中的值。类似这样的:
[globalVar = GP:tx_news_pi1|settings|templateLayout=30]
page{
includeJSFooter {
test = EXT:mytheme/Resources/Public/JavaScript/news-test.js
}
}
[global]
但是这种情况不起作用。所以我的问题:什么是错的?我怎样才能管理这个工作,为病情获得正确的价值? 我希望任何人都可以提前帮助,thanx。
答
条件[globalVar = GP:tx_news_pi1|settings|templateLayout=30]
指的是使用HTTP请求发送的数据,在这方面情况并非如此。 settings
是在TYPO3后端中创建的插件元素内的TypoScript和FlexForm部分的一部分。
我的建议是扩展你的Fluid模板并在那里加载一致的资源。您也可以使用指向该文件的其他设置。
新的TypoScript设置新闻:
plugin.tx_news.settings.Mytheme {
customLibrary = EXT:mytheme/Resources/Public/JavaScript/news-test.js
}
内流体进入:
{namespace n=GeorgRinger\News\ViewHelpers}
<f:switch expression="{settings.templateLayout}">
<f:case value="10">
... use layout 1
</f:case>
<f:case value="20">
... use layout 2
</f:case>
<f:case value="30">
... use layout 3
<n:includeFile path="{settings.Mytheme.customLibrary}" />
</f:case>
</f:switch>
上面的例子使用EXT的IncludeFileViewHelper:新闻
为了完整:一个例子,如何使用模板选择器也可以在[新闻扩展的官方手册]中找到(https://docs.typo3.org/typo3cms/extensions/news/AdministratorManual/Templates/TemplateSelector/Index.html) –