typo3

How to access constants from extension?


How can I access the constants (options) of an extension in my Site sets settings? For example: I´ve news running and want to configure it via my Site sets settings.

Thanks!


Solution

  • You have to use the other way round: use values of your SiteSet as constants.

    Have a look for details in Feature: #91080 - Site settings as TypoScript constants and in TSconfig

    Example

    We'll set the CSS file of EXT:news.

    The TypoScript looks lieke this:

    plugin.tx_news {
        settings {
            cssFile = {$plugin.tx_news.settings.cssFile}
        }
    }
    

    For setting this constant via SiteSettings, your Site settings definition (settings.definitions.yaml) should look like:

    settings:
      plugin.tx_news.settings.cssFile:
        label: 'Path to CSS file'
        type: string
        default: 'EXT:news/Resources/Public/Css/news-basic.css'