How to get TYPO3 extension configuration at TypoScript constants?

According to TYPO3 standard, It's best practice to configure the ext_conf_template.txt file into your custom TYPO3 extension - to provide global TYPO3 configuration. In such situation, if you want to get TYPO3 extension configuration to your template (via TypoScript constants), then perform below steps.

 

// setup.typoscript
plugin.yourextension.settings {
    imageTypes = 
    imageMaxSize = 
}

// ext_localconf.php

// Extension Settings Constants register for the use in basic constants:
if (version_compare(TYPO3_branch, '9.0', '>=')) {
    $nsHelpdeskExtConf = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['yourextension'];
} else {
    $nsHelpdeskExtConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['yourextension']);
}

// Add TypoScript Constants
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptConstants(
    'plugin.tx_nshelpdesk_helpdesk.imageMaxSize = 
    ' . $nsHelpdeskExtConf['imageMaxSize']
    . "\n plugin.tx_nshelpdesk_helpdesk.imageTypes = " 
    . $nsHelpdeskExtConf['imageTypes']
);

 

Now you can use this TypoScript constant to your Fluid-templates or TypoScript-configuration

Post a Comment

×
Captcha Code Can't read the image? Click here to refresh

    Got answer to the question you were looking for?