TYPO3:用于Extbase扩展的RealURL语言切换

时间:2015-11-01 07:13:55

标签: typo3 extbase realurl

我已经设置了一个使用不同语言的单域网站并配置了RealURL。

在一个页面上,有一个包含列表和显示操作的FE插件。从列表到show动作的链接正确呈现,例如:

en/press.html -> en/press/release1.html
en/press.html -> en/press/release2.html

单击其中一个链接会显示详细信息页面 - 到目前为止,非常好。一切都按预期工作。

但是,语言切换返回以下链接(在详细信息页面上):

en/press.html
de/presse.html

链接当然应如下所示:

en/press/release1.html
de/presse/aussendung1.html

此外,面包屑菜单不显示详细信息页面;它会显示Home > Press,无论我是在列表中还是显示操作。

语言导航

temp.langNav = COA
temp.langNav {
  10 = HMENU
  10 {
    special = language
    special.value = 0,1,2,3,4,5,6,7,8
    special.normalWhenNoLanguage = 0
    wrap = <ul class="lang-sel__list">|</ul>
    1 = TMENU
    1 {
      noBlur = 1
      NO = 1
      NO {
        allWrap = <li class="lang-sel__item">|</li>
        ATagParams = class="lang-sel__link"
        stdWrap.setCurrent = English || Deutsch || Русский || Česky || Polski || Français || Română || Hrvatski || Slovenčina
        stdWrap.current = 1
      }

      USERDEF1 = 1
      USERDEF1 {
        doNotLinkIt = 1
        stdWrap.cObject = TEXT
        stdWrap.cObject.value =
      }
    }
  }
}

temp.selectedLang = TEXT
temp.selectedLang.value < config.language

面包屑导航

temp.breadcrumbNav=COA
temp.breadcrumbNav {
10 = HMENU
10 {
 special = rootline
 special.range = 0|-1
 includeNotInMenu = 1
 wrap = |
 1 = TMENU
     1.noBlur = 1
     1.CUR = 1
     1.wrap = |
     1.NO {
         stdWrap.field = title
         ATagParams = class="main-header__breadcrumb-link"
         ATagTitle.field = nav_title // title
         linkWrap = <li class="main-header__breadcrumb-item">|</li>
     }
     1.CUR {
         stdWrap.field = title
         linkWrap = <li class="main-header__breadcrumb-item">|</li>
         doNotLinkIt = 1
         }
    }
}

RealURL配置

$TYPO3_CONF_VARS['FE']['addRootLineFields'].= ',tx_realurl_pathsegment';

$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
    '_DEFAULT' => array(
        'init' => array(
            'enableCHashCache' => 1,
            'appendMissingSlash' => 'ifNotFile',
            'enableUrlDecodeCache' => 1,
            'enableUrlEncodeCache' => 1,
            'postVarSet_failureMode' => '',
        ),
        'redirects' => array(),
        'preVars' => array(
            array(
                'GETvar' => 'L',
                'valueMap' => array(
                    'en' => 0,
                    'de' => 1,
                    'ru' => 2,
                    'cz' => 3,
                    'pl' => 4,
                    'fr' => 5,
                    'ro' => 6,
                    'hr' => 7,
                    'sk' => 8
                ),
                'valueDefault' => 'en',
            ),
        ),
        'pagePath' => array(
            'type' => 'user',
            'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'expireDays' => 7,
            'rootpage_id' => 1,
            'firstHitPathCache' => 1,
        ),
        'fixedPostVars' => array(
            '_DEFAULT' => array(
                array(
                    'GETvar' => 'press',
                    'lookUpTable' => array(
                        'table' => 'tx_myext_domain_model_press',
                        'id_field' => 'uid',
                        'alias_field' => 'title',
                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => 1,
                        'useUniqueCache_conf' => array(
                            'strtolower' => 1,
                            'spaceCharacter' => '-'
                        ),
                        'languageGetVar' => 'L',
                        'languageField' => 'sys_language_uid',
                        'transOrigPointerField' => 'l10n_parent',
                    )
            )
        ),
        'fileName' => array(
            'defaultToHTMLsuffixOnPrev' => 1
        ),
    ),
);

1 个答案:

答案 0 :(得分:1)

您需要告诉TYPO3保留参数。

这是通过在addQueryString ConentObject中配置HMENU来完成的。 您的示例将扩展为:

temp.breadcrumbNav=COA
temp.breadcrumbNav {
    10 = HMENU
    10 {
        1 {
            NO {
                addQueryString.exclude = L,cHash
            }
        }
    }
}

有关详细信息,请查看文档:

docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Hmenu/Index.htmldocs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink/Index.html

上面的解决方案可以在伪造:https://forge.typo3.org/issues/16466#note-3

找到