[TYPO3] typolink with cli / backend plugin
Peter Klein
peter at umloud.dk
Thu Feb 15 16:42:12 CET 2007
Hi Klaus.
All the "tslib" classes are for use in Frontend plugins. And what you are
trying to make (cli script) is a Backend feature.
As you cli script has no connection to the pages or content.
But if you REALLY need it, you'll have to include 7 classes (maybe more),
create a fake TSFE array, and initialize your cObj.
Something like this:
require_once(PATH_tslib.'class.tslib_fe.php');
require_once(PATH_t3lib.'class.t3lib_userauth.php');
require_once(PATH_tslib.'class.tslib_feuserauth.php');
require_once(PATH_t3lib.'class.t3lib_cs.php');
require_once(PATH_tslib.'class.tslib_content.php');
require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
require_once(PATH_t3lib.'class.t3lib_page.php');
$TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');
$id = isset($HTTP_GET_VARS['id'])?$HTTP_GET_VARS['id']:0;
$GLOBALS['TSFE'] = new $TSFEclassName($TYPO3_CONF_VARS, $id, '0', 1, '',
'','','');
$GLOBALS['TSFE']->connectToMySQL();
$GLOBALS['TSFE']->initFEuser();
$GLOBALS['TSFE']->fetch_the_id();
$GLOBALS['TSFE']->getPageAndRootline();
$GLOBALS['TSFE']->initTemplate();
$GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site;
$GLOBALS['TSFE']->forceTemplateParsing = 1;
$GLOBALS['TSFE']->getConfigArray();
$cObj = t3lib_div::makeInstance('tslib_cObj');
$cObj->start(array(),'');
echo $cObj->getTypoLink('Visit TYPO3.ORG','www.typo3.org');
--
Peter Klein/Umloud Untd
"Klaus Hinum" <k_hinum at hotmail.com> skrev i en meddelelse
news:mailman.1.1171484597.3836.typo3-english at lists.netfielders.de...
> hi group,
>
> my problem is that i want to create a typolink in a cli plugin but nothing
> works.
>
> i have instanced tslib_pibase.php bug i always get errors if i call the
> getTypoLink_URL function.
>
> Something like this:
> Fatal error: Call to a member function on a non-object in
> /srv/www/typo3_src/typo3_src-4.0.4/typo3/sysext/cms/tslib/class.tslib_content.php
> on line 5396
>
> I have somehow found out that a missing cObj is a problem, but creating
> one:
> $local_cObj = t3lib_div::makeInstance('tslib_cObj');
> $local_cObj->start($row, 'tt_content');
>
> does also not help.
> Any ideas?
>
> regards Klaus
More information about the TYPO3-english
mailing list