Issue Bug Closed

#106069TypoScript constants not available in addToList()

Netresearch DTT GmbH 02/03/25, 16:09 updated 10/02/26, 12:09

Description

I have a problem very similar to #102742 or maybe the same.

I have a constants.typoscript file

plugin {
    tx_myplugin{
        settings {
            myCustomPageDokType = 123
        }
    }
}

I also have the following entry in my User.tsconfig:

options.pageTree.doktypesToShowInNewPageDragArea := addToList({$plugin.tx_myplugin.settings.myCustomPageDokType})

The following is displayed in the configuration (BE_USER -> getTSConfig) view in the backend:

options.
    pageTree.
        doktypesToShowInNewPageDragArea = 1,6,4,7,3,254,199,{$plugin.tx_myplugin.settings.myCustomPageDokType}
<pre>

but should doktypesToShowInNewPageDragArea = 1,6,4,7,3,254,199,123

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 4

  1. Garvin Hicking commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2025-02-03T18:17:30+00:00" > 02/03/25, 18:17 </span>

    Thanks for your report!

    To understand this – did this ever work in v11 ir v12
    for you?

    I’m not fully sure how userts and tsconfig constants are handled – for pagets and tsconfig constants this should be another case probably?

  2. Netresearch DTT GmbH commented <span data-processor="relativetime" data-value="2025-02-04T07:58:48+00:00" > 02/04/25, 07:58 </span>

    In v11 and v12 (it would still work in v13), I have solved it so far using addUserTSConfig() in ext_localconf.php and calling a method there that returns the ID stored in the extension configuration (ext_conf_template.txt).

    ExtensionManagementUtility::addUserTSConfig(
        'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . Configuration::geMyCustomPageDokType() . ')'
    );

    With v13, addUserTSConfig is deprecated and will be removed in v14:

    Call to deprecated method addUserTSConfig() of class TYPO3\CMS\Core\Utility\ExtensionManagementUtility:
    since TYPO3 v13.0, will be removed in TYPO3 v14.0

    That’s why I wanted to rebuild it.

  3. Georg Ringer commented and changed status Needs Feedback Closed <span data-processor="relativetime" data-value="2026-10-02T12:09:55+00:00" > 10/02/26, 12:09 </span>

    Thanks for the report and the background on what you actually want to achieve. This works as designed, but there is a replacement for addUserTSConfig() that covers your use case.

    Why the constant is not replaced

    • User TSconfig does not support constants at all, the {$...} syntax is left untouched. That is why addToList() appends the literal string.
    • Page TSconfig does support {$...}, but the values come from the site settings, not from TypoScript constants. TypoScript constants like plugin.tx_myplugin.settings... have never been available in TSconfig.
    • User TSconfig is not bound to a site, so site settings cannot be used there either.

    How to replace addUserTSConfig()

    Since TYPO3 v13.0, the PSR-14 event BeforeLoadedUserTsConfigEvent can be used to add user TSconfig generated in PHP. It is the direct replacement for your current addUserTSConfig() call:

    use TYPO3\CMS\Core\Attribute\AsEventListener;
    use TYPO3\CMS\Core\TypoScript\IncludeTree\Event\BeforeLoadedUserTsConfigEvent;
    
    final class AddCustomDoktypeToNewPageDragArea
    {
        #[AsEventListener]
        public function __invoke(BeforeLoadedUserTsConfigEvent $event): void
        {
            $event->addTsConfig(
                'options.pageTree.doktypesToShowInNewPageDragArea := addToList('
                . Configuration::geMyCustomPageDokType() . ')'
            );
        }
    }

    The added TSconfig is considered static and is cached, which fits a value from the extension configuration. After changing the extension configuration, the caches need to be flushed.

    See Feature: #101838 – BeforeLoadedUserTsConfigEvent for details.

    As this is not a bug and the event solves your use case, I’m closing the issue. Feel free to comment if anything is missing.