如何在我的打字稿中设置 tx_news 特定条件?

How to set tx_news specific conditions in my typoscript?

为了显示新闻,我制作了不同的模板布局供后端编辑器选择,在我的主题的 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
    }

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

<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。 所以我试图在打字错误的条件下包含 js,询问此 templateLayout 设置中的值。像这样:

[globalVar = GP:tx_news_pi1|settings|templateLayout=30]
page{
    includeJSFooter {
        test = EXT:mytheme/Resources/Public/JavaScript/news-test.js
    }
}
[global]

但是这个条件不成立。所以我的问题是:怎么了?我如何管理它才能工作,以获得条件的正确值? 我希望任何人都可以帮助,提前谢谢。

条件[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
}

进入 Fluid 内部:

{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:news

IncludeFileViewHelper