Apr 12, 2012

When not to use typoLink

For a long time I tell everybody to use typoLink to create links inside TYPO3.

A “go”:

$url = $this->cObj->typoLink_URL(array(
    'parameter' => $GLOBALS['TSFE']->id

A “no go”:

$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

But there is one case when you absolutely must not use typoLink to create the URL. It is when the URL points to the eID script. Why? Because there is no resolving of the speaking URL inside eID anyway. So it is a complete waste of time and memory to have something like /path/to/my/news/page/news/how-i-bought-a-car.html?eID=tx_myext_eid.

Just do it like this:

$url = t3lib_div::locationHeaderUrl('index.php?eID=tx_myext_eid').

That's the right way.


  1. eID is often used for AJAX requests and from that point of view you're absolutely right.
    But there might also be cases where eID puts out whole HTML-Pages. Those documents better have speaking URLs for the convenience of the users and ranking in search engines.

  2. Probably the best in this case, it's to use RewriteRule for eID scripts on the level of .htaccess.

  3. One should also point that for performance reason (when generating thousands of links), using typoLink might prove unfeasible.

  4. Thanks this was really helpful to me.:)

  5. tuzi gand
    @Dmitry Dulepov:-
    This wass a nice post which really help me a lot thnx in advance :) but i would like to know more about .htaccess and its benefits.Waiting for you valuable reply. Thank you againg