Skip to content

Instantly share code, notes, and snippets.

@markuspoerschke
Last active December 19, 2015 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markuspoerschke/5933531 to your computer and use it in GitHub Desktop.
Save markuspoerschke/5933531 to your computer and use it in GitHub Desktop.
TYPO3: Using typolink in scheduler
# In your TypoScript you should add the absolute prefix
# or URL would look like this: http://www.example.com/var/www/news/mein-artikel
config.absRefPrefix = /
<?php
// ...
protected function initTsfe() {
global $TYPO3_CONF_VARS;
$id = $this->pageId;
$rootline = t3lib_BEfunc::BEgetRootLine($id);
$host = t3lib_BEfunc::firstDomainRecord($rootline);
$_SERVER['HTTP_HOST'] = $host;
$GLOBALS['TT'] = t3lib_div::makeInstance('t3lib_timeTrack');
$GLOBALS['TT']->start();
$GLOBALS['TSFE'] = t3lib_div::makeInstance('tslib_fe', $TYPO3_CONF_VARS, $id, 0);
$GLOBALS['TSFE']->connectToDB();
$GLOBALS['TSFE']->initFEuser();
$GLOBALS['TSFE']->determineId();
$GLOBALS['TSFE']->initTemplate();
$GLOBALS['TSFE']->getConfigArray();
}
// ...
public function getLink($linkPid) {
$this->initTsfe(); # Call this only once! Move to constructor!
$cObj = t3lib_div::makeInstance('tslib_cObj');
$cObj->typolink_URL(array('parameter' => $linkPid));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment