typo3typoscripttypo3-6.1.xtypo3-6.2.xtypo3-4.5

How to call baseurl in TYPO3 Back End Module Extension


I want to call base-url for my custom TYPO3 backend module extension. Is there any built in function for that. If not how to configure one constant and call it?

Any Ideas please share.

Note:I'm using TYPO3. 6.2.9


Solution

  • Found this as a workaround:

    The function is trying to get the baseURL set in config.baseURL. If the baseurl isn't set in the typoscript setup it will use "$_SERVER['SERVER_NAME']" as base.

    Maybe it will help..

    function loadTS($pageUid) {
        $backendUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Utility\\BackendUtility');
        $rootLine = $backendUtility->BEgetRootline($pageUid);
        $TSObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\TemplateService');
        $TSObj->tt_track = 0;
        $TSObj->init();
        $TSObj->runThroughTemplates($rootLine);
        $TSObj->generateConfig();
        return $TSObj->setup;
    } 
    
    $TS = $this->loadTS('1');
    
    !$TS['config.']['baseURL']) 
    { 
        $baseURL = 'http://'.$_SERVER['SERVER_NAME'].'/';
    } 
    else 
    {
        $baseURL = $TS['config.']['baseURL'];
    }