How to get TYPO3 extension configuration at TypoScript constants?

Category : Extensions , By : Nilesh Malankiya

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

To keep improving, Do you have feedback and suggestions? Or, Are you facing any issues to implement above TYPO3 tutorial? Feel free to write your comment at below comment box; I'll happy to help you :)

Post Comment

Your email address will not be published. Required fields are marked *

×

Name is required!

Enter valid name

Valid email is required!

Enter valid email address

Comment is required!

Google Captcha Is Required!

Be the First to Comment

Stay up to date with our recent TYPO3 Blogs, news, & updates