How to set tx_news special conditions in my typoscript?

To display the news, I developed various template layouts to select for backend editors configured in the pageTSconfig file:

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
    }

In my liquid pattern, I can switch conditions like

<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>

Everything works very well so far here.

Now I want to embed javascript for only one of these template layouts. So I tried to include js in the condition in typoscript by requesting a value in this templateLayout setting. Something like that:

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

But this condition does not work. So my question is: what's wrong? And how can I manage this to work in order to get the right value for the condition? I hope someone can help, thanks in advance.

+4
1

[globalVar = GP:tx_news_pi1|settings|templateLayout=30] , HTTP-, . settings TypoScript FlexForm , TYPO3.

, 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>

IncludeFileViewHelper EXT: news

+6

Source: https://habr.com/ru/post/1657304/


All Articles