[TYPO3-dev] Create correct (typo-) links in extension?

Bernhard Kraft kraftb at think-open.at
Sun Dec 13 16:27:07 CET 2009


Gerhard Mehsel wrote:

 > $linkTxt = 'Here I want to have the page title, not the PID';
 > $pid = 123;
 > $cObj = t3lib_div::makeInstance('tslib_cObj');
 > $conf = array('parameter'=> $pid);
 > return $cObj->getTypoLink($linkTxt, $conf);

The method you are using, requires the second parameter to just be the 'parameter' value, not an array. So you either use:

return $this->cObj->getTypoLink($linkTxt, $pid);

Or you use the method "typoLink", which requires an typoScript configuration array to be passed:

return $this->cObj->typoLink($linkTxt, $conf);

But the best thing would anyways be, to define the configuration in TypoScript like:

plugin.tx_myext_pi1.myLink = TEXT
plugin.tx_myext_pi1.myLink.value = Here I want to have the page title
plugin.tx_myext_pi1.myLink.typolink {
	parameter.current = 1
}

And then use PHP code like the following:

$this->cObj->setCurrentVal($pid);
return $this->cObj->cObjGetSingle($this->conf['myLink'], $this->conf['myLink.']);

This would render the above defined cObject, allowing you to define all aspects of the link/label via TypoScript


greets,
Bernhard




More information about the TYPO3-dev mailing list