更新。 f:link.page有时会用错误的语言创建链接

时间:2016-08-25 15:27:58

标签: typo3 typo3-7.6.x realurl

更新
在为站点创建新翻译并调用它时,realURL会缓存路径。然后,当您更改此站点的标题时,将生成一个新路径 旧路径仍然在缓存中,因此两个路径都有效。

是否有可能迫使realURL仅输出新路径,但保留旧路径以使它们仍然有效?

旧问题:

我发现菜单有一种奇怪的行为。有时它会创建错误链接的链接。为了解释它,我将创建一个例子:

Lets say I have following sitestructure in defaultlanguge:
/the-thing/home

So for english(UK) I have the following URL:
/uk/the-thing/home

But for german I have:
/de/das-ding/home  (the-thing is translated to german)

但有时f:link.pagef:link.typolink会使用默认结构名创建德语链接。对于上面的示例,这意味着/de/the-thing/home

当我在后端登录时,此链接将,但当我未在后端登录时,链接正常工作

这不仅发生在菜单中,所以我不会发布菜单代码,因为它有点复杂。但我会发布这个:

<f:link.typolink parameter="{langele.language.url}" additionalParams="&L={langele.language.language}">{langele.language.languagename}</f:link.typolink>

Example values:
{langele.language.url}: 11 (page_uid)
{langele.language.language}: 2 (sys_language_uid)
{langele.language.languagename}: Just a textfield

此代码位于一个contentelement,用于创建指向其他语言的链接,并以默认语言放置。

语言是单一的,翻译的页面只有另一个页面标题。我不使用替代导航标题。我使用realURL。我的realURL配置没有太多修改(大多数配置用于扩展,404处理):

<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']=array (
  '_DEFAULT' => 
  array (
    'init' => 
    array (
      'appendMissingSlash' => 'ifNotFile,redirect',
      'emptyUrlReturnValue' => '/',
    ),
    'pagePath' => 
    array (
      'rootpage_id' => '1',
    ),
    'fileName' => 
    array (
      'defaultToHTMLsuffixOnPrev' => 0,
      'acceptHTMLsuffix' => 1,
      'index' => 
      array (
        'print' => 
        array (
          'keyValues' => 
          array (
            'type' => 98,
          ),
        ),
      ),
    ),
    'preVars' => 
    array (
      0 => 
      array (
        'GETvar' => 'L',
        'valueMap' => 
        array (
            'ch' => 1,
            'uk' => 2,
            'au' => 3,
            'at' => 4,
            'ca' => 5,
            'hr' => 6,
            'cy' => 7,
            'fi' => 10,
            'de' => 12,
            'hu' => 13,
            'it' => 15,
            'sa' => 16,
            'nl' => 18,
            'no' => 19,
            'sg' => 20,
            'es' => 23,
            'se' => 24,
            'tr' => 26,
            'ae' => 27,
            'us' => 28
        ),
        'noMatch' => 'bypass',
      ),
    ),
    'postVarSets' => 
    array (
      '_DEFAULT' => 
      array (
        'news' => array(
            array(
                    'GETvar' => 'tx_news_pi1[action]',
            ),
            array(
                    'GETvar' => 'tx_news_pi1[controller]',
            ),
            array(
                    'GETvar' => 'tx_news_pi1[news]',
                    'lookUpTable' => array(
                            'table' => 'tx_news_domain_model_news',
                            'id_field' => 'uid',
                            'alias_field' => 'title',
                            'addWhereClause' => ' AND NOT deleted',
                            'useUniqueCache' => 1,
                            'useUniqueCache_conf' => array(
                                    'strtolower' => 1,
                                    'spaceCharacter' => '-',
                            ),
                            'languageGetVar' => 'L',
                            'languageExceptionUids' => '',
                            'languageField' => 'sys_language_uid',
                            'transOrigPointerField' => 'l10n_parent',
                            'autoUpdate' => 1,
                            'expireDays' => 180,
                    ),
            ),
        ),
        'collection' => array(
            array(
                'GETvar' => 'tx_mystuff_collection[mystuff]',
                'lookUpTable' => array(
                            'table' => 'tx_mystuff_domain_model_mystuff',
                            'id_field' => 'uid',
                            'alias_field' => 'name',
                            'addWhereClause' => ' AND NOT deleted',
                            'useUniqueCache' => 1,
                            'useUniqueCache_conf' => array(
                                    'strtolower' => 1,
                                    'spaceCharacter' => '-',
                            ),
                            'languageGetVar' => 'L',
                            'languageExceptionUids' => '',
                            'languageField' => 'sys_language_uid',
                            'transOrigPointerField' => 'l10n_parent',
                            'autoUpdate' => 1,
                            'expireDays' => 180,
                    ),
            ),
            array(
                'GETvar' => 'tx_mystuff_collection[action]',
            ),
            array(
                'GETvar' => 'tx_mystuff_collection[controller]',
            ),


        ),
      ),
    ),
  ),
);

# 404 Errorhandling

if (preg_match('/\/ch\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 1) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/ch/404/';
} else if (preg_match('/\/gb\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 2) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/uk/404/';
} else if (preg_match('/\/au\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 3) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/au/404/';
} else if (preg_match('/\/at\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 4) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/at/404/';
} else if (preg_match('/\/ca\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 5) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/ca/404/';
} else if (preg_match('/\/hr\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 6) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/hr/404/';
} else if (preg_match('/\/cy\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 7) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/cy/404/';
} else if (preg_match('/\/fi\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 10) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/fi/404/';
} else if (preg_match('/\/de\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 12) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/de/404/';
} else if (preg_match('/\/hu\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 13) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/hu/404/';
} else if (preg_match('/\/it\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 15) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/it/404/';
} else if (preg_match('/\/sa\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 16) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/sa/404/';
} else if (preg_match('/\/nl\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 18) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/nl/404/';
} else if (preg_match('/\/no\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 19) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/no/404/';
} else if (preg_match('/\/sg\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 20) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/sg/404/';
} else if (preg_match('/\/es\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 23) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/es/404/';
} else if (preg_match('/\/se\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 24) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/se/404/';
} else if (preg_match('/\/tr\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 26) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/tr/404/';
} else if (preg_match('/\/ae\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 27) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/ae/404/';
} else if (preg_match('/\/us\//', $_SERVER['REQUEST_URI']) || $_GET['L'] == 28) {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/us/404/';
} else  {
  $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/uk/404/';
}

我的语言的Typoscript(为了德语和荷兰语保持小,其他语言类似):

config {
  sys_language_uid = 0
  language = en
  locale_all = en_EN

}

[globalVar = GP:L = 12]
config {
  sys_language_uid = 12
  language = de
  locale_all = de_DE
  sys_language_overlay = hideNonTranslated
  sys_language_mode = strict
}
  lib.language.value = 12

plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 12
plugin.tx_indexedsearch.settings.languageUid = 12
[global]

[globalVar = GP:L = 18]
config {
  sys_language_uid = 18
  language = nl
  locale_all = nl_NL
  sys_language_overlay = hideNonTranslated
  sys_language_mode = strict
}
  lib.language.value = 18

  plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 18
plugin.tx_indexedsearch.settings.languageUid = 18
[global]

不幸的是我不确定如何重现这一点。我发现荷兰语中的某些链接总是正确的,而其他链接则不是。

我的猜测是:页面被翻译并调用,但标题没有改变,因此默认标题被采用并且它被缓存。然后标题被更改,新的URL也被缓存了。这符合以下事实:&#34;错误&#34;登录后端时URL不起作用,因为据我所知,在您登录时系统不会使用某些缓存。

(虽然我写了这个问题但我现在认为我的猜测是真的,有人可以证实吗?)

有没有办法优先考虑一个URL而不是另一个?我希望看到更新的/当前的标题,URL。

遗憾的是,此时删除它是不可能的,因为我们发送了一些错误的&#34;简报中的网址,如果我们能够保持错误的话,那就太好了。一个月的网址,但仅使用菜单/链接的当前网址。

有什么办法吗?

0 个答案:

没有答案