[TYPO3-dev] How to create a realurl link in a scheduler task?

Jigal van Hemert jigal at xs4all.nl
Wed Jan 11 09:27:47 CET 2012


Hi,

In a scheduler task I need to create a link to a page (with some 
additional parameters) and it preferably needs to be processed by realurl.

typolink needs a tslib_cObj instance and this needs a frontend. I have 
succeeded in initializing a frontend by using:

$GLOBALS['TSFE'] = t3lib_div::makeInstance('tslib_fe',
     $GLOBALS['TYPO3_CONF_VARS'], $pageUid, 0);
$GLOBALS['TSFE']->sys_page =
     t3lib_div::makeInstance('t3lib_pageSelect');
$GLOBALS['TSFE']->sys_page->init(TRUE);
$GLOBALS['TSFE']->initTemplate();
$GLOBALS['TSFE']->rootLine =
     $GLOBALS['TSFE']->sys_page->getRootLine($pageUid, '');
$GLOBALS['TSFE']->getConfigArray();

This results in a relative link, but a simple fix is available:
if (t3lib_extMgm::isLoaded('realurl') && $this->isMultiDomain()) {
   $rootline = t3lib_BEfunc::BEgetRootLine($pageUid);
   $host = t3lib_BEfunc::firstDomainRecord($rootline);
   $_SERVER['HTTP_HOST'] = $host;
}

Now I can make an instance of tslib_cObj, configure and call typolink to 
get an absolute URL, but there are still too issues:

- PATH_site is the complete path to the scripts in the file system if 
the scheduler task is invoked by the cron job (like: 
var/www/html/domain.ext/)

- the link is not a speaking URL (result is 
http://domain.ext/var/www/html/domain.ext/index.php?id=38&tx_myext_pi1[myvar]=2 
)

Any suggestions?

-- 
Kind regards / met vriendelijke groet,

Jigal van Hemert.



More information about the TYPO3-dev mailing list