for displaying news i´ve made different template layouts to choose for backend editors, configured in my theme´s 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
}
In my fluid template 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 fine until here.
Now i want to embed javascript for only one of these template layouts. So i tried to include the js within a condition in typoscript, asking for the value in this templateLayout setting. Something like this:
[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: What is wrong? And how can i manage this to work, to get the right value for the condition? I hope anyone can help, thanx in advance.
The condition [globalVar = GP:tx_news_pi1|settings|templateLayout=30]
refers to data that has been sent using an HTTP request which is not the case in that regard. settings
are part of the TypoScript and FlexForm part inside the plugin element that has been created in the TYPO3 backend.
My suggestion is to extend your Fluid templates and load the accordant resource there. You could use an additional setting pointing to the file as well.
New TypoScript setting for news:
plugin.tx_news.settings.Mytheme {
customLibrary = EXT:mytheme/Resources/Public/JavaScript/news-test.js
}
Access inside 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>
The example above uses the IncludeFileViewHelper of EXT:news
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With