Search code examples
typo3typoscript

Is there any difference between the syntax used for TypoScript constants and the syntax for "Extension Configuration"?


For both "TypoScript constants" and "Extension Configuration" (as defined in ext_conf_template.txt) use a common syntax. They are documented here:

An example:

# cat=basic; type=string; label=Some title
title = 

Line 1 describes data type, category etc. of the variable.

Alternatively, we might have something like this:

tx_plugins.my_plugin {
    # cat=basic; type=string; label=Some title
    title = 

}

Besides this rather simple example, there are some more things you can do with this.

Where TypoScript constants and Extension Configuration are stored and how they are used is completely different, but I am wondering if we just look at the syntax and the features you can use - is it the same?

e.g.

  • the available datatypes (boolean, integer etc.)
  • that you can't use multiline values
  • that you can use environment variables
  • how to access files
  • how to do localization

The reason I ask: To streamline the documentation and also I use this in my own extensions.


Solution

  • Short Answer

    The syntax used for TS template constants and extension configuration is the same but there are some minor differences for the available types currently.

    Deep Analysis

    Extension Configuration

    For TYPO3 CMS version 6 the extension manager and configuration was rewriten from scratch based on Extbase and using the FormEngine. Available types are:

    • int: integer values
    • int+: positive integer values only
    • integer: alias for int
    • color: color picker
    • wrap: wrap, lines are separated finally by | for the saved value
    • offset: offset field
    • options: select
    • boolean: checkbox
    • user: user function is used for rendering
    • small: small text field
    • string: text field
    • input: alias for string, only for backwards compatibility, many extensions depend on that
    • default: alias for string, only for backwards compatibility, many extensions depend on that

    Source is available here: https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Classes/ViewHelpers/Form/TypoScriptConstantsViewHelper.php#L36

    TypoScript Template Constant Editor

    On the other hand the TypoScript template constant editor was never rewriten to make use of the FormEngine and has it's own implementation. Here the following types are additionally available:

    • comment: a checkbox to switch a constant
    • files: file selection

    Source is available here: https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php#L993

    Other Questions

    • that you can't use multiline values

    That's almost true for the TS constant editor but there is the wrap type to achieve a multiline like functionality. For the extension configuration there are the small and string types.

    For the other questions I'm currently not aware of and have to investigate a little bit deeper first:

    • that you can use environment variables
    • how to access files
    • how to do localization