Typo3 getTypoLink_URL creates wrong link after language change

454 views Asked by At

I hope I can manage to explain this problem...

I have an T3-extension that handles shared content.

In this shared content, we have links (page-ids) that are defined and converted into something like /en/clients/contact, using

$cObj = t3lib_div::makeInstance('tslib_cObj');
$href = $cObj->getTypoLink_URL($linkValue); // $linkValue is an integer (e.g. 153)

This works fine - until I change the language on the page. Then, the last used URL kinda «sticks» and the language indicator isn't present in the URL anymore.

Means:

  • call the german page -> works
  • change to english -> works
  • change back to german -> the english link is presented.

So the above link turns out like clients/contact (the leading slash is gone as well).

Oddly enough, I have a local installation of the same page where the problem doesn't occur. It's just on the page that's online.

I tried to find differences in the configuration, but there aren't any.

The only difference I could find so far is, that I use Typo3 v4.5.35 for the local installation and v4.7.17 for the online installation.

Any ideas???

1

There are 1 answers

0
Swissdude On

This was very odd... but, I found a solution.

Instead of using $cObj->getTypoLink_URL($linkValue); I'm using this:

$configurations['additionalParams'] = "&L=".(int)t3lib_div::_GP('L');
$configurations['returnLast'] = 'url'; // get it as URL
$configurations['parameter'] =  $linkValue;
$href = $cObject->typolink(NULL, $configurations); 

It seems that when I created the $cObj, the L-Parameter got lost somewhere, somewhen. By adding it manually, the Link works as expected.