typo3typo3-13.x

How to create a condition with a variable?


Is it possible to do something like that (doesn't work):

[{mysettings.id} in tree.rootLineIds]  

@import './TypoScript/'

[END]

Background: I have a Set Set, but want to use it only on specific page-Ids (and want to set these ID via Site Settings).

Thanks!

I'm using TYPO3 13


Solution

  • You can set condition as below in setup.typoscript file

    [{$plugin.tx_myext.settings.myPageId} in tree.rootLineIds]
        @import 'EXT:my_ext/Configuration/TypoScript/'
    [global]
    

    assuming your Settings.yaml

    plugin:
      my_ext:
        settings:
          myPageId: 123
    

    settings.definitions.yaml

      plugin.tx_myext.settings.myPageId:
        category: MyExt.settings
        type: int
        label: 'Page of the MyPage'
        description: ''
        default: '0'
    

    This will only include ".typoscript" files under directory "EXT:my_ext/Configuration/TypoScript/" when the condition matches