typo3typoscriptextbase

How to access the ext_conf_template.txt (extension configuration) in typoscript?


There are a few settings in the ext_conf_template.txt in my extension.

I want to check the value of one of these settings, but in typoscript, not in PHP.

In PHP it works like this:

unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['myExt'])

How should I do this in typoscript?


Solution

  • I did something similar in my code snippet extension (see complete code on Github), where I just added a custom TypoScript condition:

    [DanielGoerz\FsCodeSnippet\Configuration\TypoScript\ConditionMatching\AllLanguagesCondition]
      // some conditional TS
    [global]
    

    The condition implementation is quite simple:

    namespace DanielGoerz\FsCodeSnippet\Configuration\TypoScript\ConditionMatching;
    use DanielGoerz\FsCodeSnippet\Utility\FsCodeSnippetConfigurationUtility;
    use TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractCondition;
    
    class AllLanguagesCondition extends AbstractCondition
    {
        /**
         * Check whether allLanguages is enabled
         * @param array $conditionParameters
         * @return bool
         */
        public function matchCondition(array $conditionParameters)
        {
            return FsCodeSnippetConfigurationUtility::isAllLanguagesEnabled();
        }
    }
    

    And the check for the actual TYPO3_CONF_VARS value is done in FsCodeSnippetConfigurationUtility:

    namespace DanielGoerz\FsCodeSnippet\Utility;    
    class FsCodeSnippetConfigurationUtility
    {
        /**
         * @return array
         */
        private static function getExtensionConfiguration()
        {
            return unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['fs_code_snippet']);
        }
        /**
         * @return bool
         */
        public static function isAllLanguagesEnabled()
        {
            $conf = self::getExtensionConfiguration();
            return !empty($conf['enableAllLanguages']);
        }
    
    }
    

    Maybe that fits your needs.