简体   繁体   English

TYPO3语言切换器未使用正确的RealURL路径

[英]TYPO3 language switcher does not use the correct RealURL paths

I use the following TypoScript to generate a language switcher. 我使用以下TypoScript生成语言切换器。 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: 现在,我使用以下RealURL设置:

$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 . 当我使用/produkte/produktuebersicht ,语言切换器会生成指向/en/produkte/produktuebersicht的链接,而不是/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: 我检查了ID到路径的映射,对我来说看起来不错:

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? 那么,如何使其链接到语言切换器中正确的RealURL?

Your RealURL pagePath section should include a languageGetVar setting. 您的RealURL pagePath部分应包含languageGetVar设置。

From the RealURL documentation: 从RealURL文档中:

Defines which GET variable in the URL that defines language id; 定义URL中定义语言ID的GET变量; 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部分应如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM