Add Additional configuration areas

Sometimes it’s necessary to add some custom areas / keys to the Typo3 configuration ($GLOBALS[‘TYPO3_CONF_VARS’]). In my case I needed some auth-data for a Magento / Typo3 crossover in a curl call.

The problem is: If you made manual changes in the typo3conf/LocalConfiguration.php , after a configuration save over the install tool, all changes will be gone (I think since v 6.2).

The solution: You can add a typo3conf/AdditionalConfiguration.php, where you can add your adjustments. For example:

<?php
$GLOBALS['TYPO3_CONF_VARS']['MAGENTO'] = array(
    'htaccess_user' => 'sheldon',
    'htaccess_pw'   => 'SHELDOisNICE'
);

Now you can get the values in any Typo3 context via:

if($GLOBALS['TYPO3_CONF_VARS']['MAGENTO']['htaccess_user']
    && $GLOBALS['TYPO3_CONF_VARS']['MAGENTO']['htaccess_pw']){
    $this->setOpt(CURLOPT_USERPWD, "{$GLOBALS['TYPO3_CONF_VARS']['MAGENTO']['htaccess_user']}:{$GLOBALS['TYPO3_CONF_VARS']['MAGENTO']['htaccess_pw']}");
    $this->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
}

 

 

Leave a Reply

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

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.