I am currently writing a scheduler for TYPO3 (4.7.7).
In my task I need some URLs for records from tt_news. I tried to "boot" the frontend as did in "pxa_newstofb" extension but this does not work. Here is my current class that should generate a link to a news record:
<?php
abstract class tx_myextension_newshelper {
/**
* @var tslib_cObj
*/
protected $cObj;
function __construct() {
}
/**
* Creates a URL for the given news
*
* @param $news
* @return string
*/
public function link($news) {
// Init frontend
$this->initTSFE($news['pid']);
$newsLink = $this->cObj->typoLink_URL(array(
'no_cache' => false,
'parameter' => $news['pid'],
'additionalParams' => '&tx_ttnews[tt_news]=' . $news['uid'],
'useCacheHash' => true
));
if (substr($newsLink, 0, 7) != 'http://' || substr($newsLink, 0, 8) != 'https://') {
$newsLink = $this->host($news) . $newsLink;
}
return $newsLink;
}
public function host($news) {
return 'http://localhost/';
}
/**
* Initialize frontend
*
* @param int $pageUid
*/
public function initTSFE($pageUid = 1) {
global $GLOBALS, $TSFE, $TYPO3_CONF_VARS;
$this->cObj = t3lib_div::makeInstance('tslib_cObj');
$temp_TTclassName = t3lib_div::makeInstance('t3lib_timeTrack');
$GLOBALS['TT'] = new $temp_TTclassName();
$GLOBALS['TT']->start();
$TSFE = new tslib_fe($TYPO3_CONF_VARS, $pageUid, 0, 0);
$TSFE->connectToDB();
$TSFE->initFEuser();
$TSFE->fetch_the_id();
$TSFE->getPageAndRootline();
$TSFE->initTemplate();
$TSFE->forceTemplateParsing = 1;
$TSFE->getConfigArray();
$TSFE->initUserGroups();
$TSFE->initTemplate();
$TSFE->determineId();
$GLOBALS['TSFE'] = $TSFE;
$this->cObj->start(array(),'');
}
}
?>
Everytime if I execute my task a "404" (frontend-)page without css will be shown. Is there a smart solution for creating frontend URLs for tt_news extension?
System: Typo3 CMS 4.7.7 Introduction Package with RealURL.