如何在我的typoscript中设置tx_news特定条件?

Mir*_*rko 4 javascript typo3 conditional-statements typoscript tx-news

为了显示新闻我已经为我的主题的PageTSconfig中配置的后端编辑器选择了不同的模板布局:

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
    }
Run Code Online (Sandbox Code Playgroud)

在我的流体模板中,我可以切换条件

<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>
Run Code Online (Sandbox Code Playgroud)

一切都很好,直到这里.

现在我想只为其中一个模板布局嵌入javascript.所以我试图将js包含在typoscript中的条件中,询问此templateLayout设置中的值.像这样的东西:

[globalVar = GP:tx_news_pi1|settings|templateLayout=30]
page{
    includeJSFooter {
        test = EXT:mytheme/Resources/Public/JavaScript/news-test.js
    }
}
[global]
Run Code Online (Sandbox Code Playgroud)

但这种情况不起作用.所以我的问题:出了什么问题?我如何管理这个工作,为条件获得正确的价值?我希望任何人都可以提前帮助.

Oli*_*der 7

该条件[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
}
Run Code Online (Sandbox Code Playgroud)

进入内部流体:

{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>
Run Code Online (Sandbox Code Playgroud)

上面的例子使用EXT 的IncludeFileViewHelper:news