All articles » Programming » Add anchor in getTypoLink
-
Add anchor in getTypoLink
written:
3 years ago
category:
Programming
Previous
Next
getTypoLink() doesn't allow you to pass an anchor parameter. So, in order to add an anchor to such a link you just have to add the anchor part to the id parameter:
$this->cObj->getTypoLink('Link Label', '123#myanchor');$this->cObj->pi_linkToPage('Link Label', '123#myanchor');$this->cObj->getTypoLink_URL('123#myanchor');By the way, ever saw what the harmless function
class.tslib_content.php:typoLink()does? Have a look just for fun, it's a 300 liner! Feels like Typo3 has a damned considerable amount of workarounds for various special cases and requirements.See also: http://www.typo3-jack.net/typo3-dev-lists-netfielders-de/3076-typo3-dev-typolink-anchor.html
Comments:

3 years ago
written by: Daniel Hahler
In TypoScript there's the "section" param for "typolink", which you can pass in $conf to the tslib_cObj::typolink (PHP) method, too.