2
votes

I use the following TypoScript to generate a language switcher. It's basically a copy from an existing site where everything works fine:

lib.langMenu = HMENU
lib.langMenu {
  special = language
  addQueryString = 1
  special.value = 0,1
  special.normalWhenNoLanguage = 0
  1 = TMENU
  1 {
    noBlur = 1
    NO = 1
    NO {
        allWrap = <li>|</li>
        stdWrap2.noTrimWrap = | | |
        stdWrap.override = Deutsch || English
        ATagParams = class="lang-switcher-de" || class="lang-switcher-en"
    }

    ACT < .NO
    ACT = 1
    ACT.allWrap = <li class="active">|</li>

    wrap = <ul class="pull-right language"><li class="hidden-xs">Language:</li>|</ul>
  }
}

Now, I use the following RealURL setup:

$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
  '_DEFAULT' => array(
    'init' => array(
      'enableCHashCache' => 1, 
      'enableUrlDecodeCache' => 1,
      'enableUrlEncodeCache' => 1,
    ),
    'preVars' => array (
      0 => array (
        'GETvar' => 'L',
        'valueMap' => array (
          'en' => '1',
        ),
        'noMatch' => 'bypass',
      ),
    ),
    'pagePath' => array(
      'type' => 'user',
      'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
    ),
   )
 );

The issue is that, say I have the following pages, with their German and English path:

  • produkte / products
    • produktuebersicht / product_overview

When I'm on /produkte/produktuebersicht, the language switcher generates a link to/en/produkte/produktuebersicht instead of /en/products/product_overview. This problem occurs on every single page.

It always takes the path of the wrong (read, current) language. I've checked the ID to path mapping and it looks fine to me:

The encode cache has these entries – but even when I delete them the problem persists:

The weird thing is that the menu itself is generated correctly. So how can I make it link to the right RealURLs in the language switcher?

1

1 Answers

3
votes

Your RealURL pagePath section should include a languageGetVar setting.

From the RealURL documentation:

Defines which GET variable in the URL that defines language id; if set the path will take this language value into account and try to generate the path in localized version.

Your pagePath section should look like:

'pagePath' => array(
  'type' => 'user',
  'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
  'languageGetVar' => 'L'
),