typo3摆脱了URL中的默认语言参数

时间:2018-04-03 09:33:06

标签: typo3 multilingual

我有一个使用RealURL的多语种TYPO3网站。德语是默认(和后备)语言,英语是翻译。我想摆脱GET参数?L = 0表示语言菜单中的默认语言。怎么做?

#language menu
config.linkVars = L(1)

language = de
locale_all = de_DE.UTF-8
sys_language_uid = 0
htmlTag_langKey = de

# Engilsh
[globalVar = GP:L=1]
    config{
        language = en
        locale_all = gb_EN.UTF-8
        sys_language_uid = 1
        htmlTag_langKey = en
    }
[global]


# <a href="#">DE</a>
# |
# <a href="en">EN</a>
lib.langMenu = HMENU
lib.langMenu{
    special = language
    special.value = 0,1
    special.normalWhenNoLanguage = 0
    1 = TMENU
    1.NO {
      stdWrap.override = DE || EN
      # this attempt is not working
      stdWrap.typolink.additionalParams  = || &L=1

    }
    1.ACT < .1.NO
    1.ACT = 1
    1.ACT{
      doNotLinkIt = 1
      allWrap = <a>|</a>
    }

}

2 个答案:

答案 0 :(得分:0)

您的第4 - 7行缺少config.前缀。 我会定义config.linkVars = L(0,1)

以下是3种语言的语言菜单示例:DE,EN,CN

lib.lang = COA
lib.lang {
 20 = HMENU
 20 {
     special = language
     special.value = 0,1,2
     addQueryString = 1
     addQueryString.exclude = id, L, cHash
     addQueryString.method = GET

     1 = TMENU
     1 {
         wrap = <ul class="menu" id="lang"> | </ul>
         noBlur = 1
         NO = 1
         NO {
             stdWrap.cObject = TEXT
             stdWrap.cObject {
                 value =   DE || EN || 中文

             }
             linkWrap = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
         }
         ACT < .NO
         ACT.ATagParams = class="active"
         ACT.linkWrap = <li class="first active">|</li> |*| <li class="active">|</li> |*| <li class="last active">|</li>

         #hide lang item in menu, if not translated
         USERDEF1 < .NO
         USERDEF1 = 1
         USERDEF1 {
             allWrap = |
             stdWrap.cObject.value =
             doNotLinkIt = 1
             linkWrap >
         }
         USERDEF2 < .NO
         USERDEF2 = 1
         USERDEF2 {
             allWrap = |
             stdWrap.cObject.value =
             doNotLinkIt = 1
             linkWrap >
         }

     }
   }
}

我必须说我们使用默认语言构建带语言段的URL路径。所以对于DE URL,我们有......像my-domain.tld/de/your/path/ 但是在TSsetup和realurl配置中设置无默认值应该为您提供默认URL而不使用路径中的默认语言。

希望有所帮助。

答案 1 :(得分:0)

解决方案:

我遇到了完全相同的问题,这就是我通过检查以下步骤来解决的问题:

  1. 将RealURL更新为最新版本(撰写本文时为 2.4.0 )。
  2. Read the documentation,并确保您的配置正确。

这是我最终得到的代码,在我的配置中,语言菜单中显示的语言参数不再存在的问题。

语言菜单文字:

lib.language = HMENU
lib.language {
    special = language
    special {
        value = 0,1
        normalWhenNoLanguage = 0
    }   
    wrap = <ul class="lang">|</ul>
    1 = TMENU
    1 {
    noBlur = 1
    NO = 1
    NO {
        linkWrap = <li>|</li>
        stdWrap.override = de || en
        htmlSpecialChars = 1
        ATagParams = class="de" || class="en"
        wrap = <span>|</span>
        doNotLinkIt = 1
        stdWrap.typolink {
            parameter.data = page:uid
            additionalParams = &L=0 || &L=1
            addQueryString = 1
            addQueryString.exclude = L,id,cHash,no_cache
            addQueryString.method = GET
            useCacheHash = 1
            no_cache = 0
            ATagParams = class="de" || class="en"
            ATagBeforeWrap = 1
            wrap = <span>|</span>
        }
    }
    ACT <.NO
    ACT {
        linkWrap = <li>|</li>
        stdWrap.override = de || en
        htmlSpecialChars = 1
        doNotLinkIt = 1
        stdWrap.typolink {
            parameter.data = page:uid
            addQueryString = 1
            addQueryString.exclude = L,id,cHash,no_cache
            addQueryString.method = GET
            useCacheHash = 1
            no_cache = 0
            ATagParams = class="de act" || class="en act"
            ATagBeforeWrap = 1
            wrap = <span>|</span>
        }
    }
    USERDEF1 < .NO
    USERDEF1 {
        linkWrap = <li>|</li>
        doNotLinkIt = 1
    }
    USERDEF2 < .ACT
    }
}

基本RealURL配置:

<?php 
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = array(

    'init' => array(
        'enableCHashCache' => true,
        'appendMissingSlash' => 'ifNotFile',
        'enableUrlDecodeCache' => true,
        'enableUrlEncodeCache' => true,
        'appendMissingSlash' => 'ifNotFile,redirect[301]', 
    ),
    'redirects' => array(),

    'preVars' => array(
        0 => array(
            'GETvar' => 'L',
            'valueMap' => array(
                'en' => 1,
            ),
            'noMatch' => 'bypass',
        ),
        array(
            'GETvar' => 'no_cache',
            'valueMap' => array(
                'nc' => 1,
            ),
            'noMatch' => 'bypass',
        ),
    ),

    'pagePath' => array(
        'type' => 'user',
        'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
        'spaceCharacter' => '-',
        'languageGetVar' => 'L',
        'expireDays' => 7,
        'disablePathCache' => '1',
        'rootpage_id' => '1',
        'postVarSet_failureMode'=>'',
        'firstHitPathCache' => 1,
        'emptyUrlReturnValue' => '/',
    ),

    'fileName' => array (
    'defaultToHTMLsuffixOnPrev' => false,
    'index' => array(
        'index.html' => array('keyValues' => array ('type' => 1,),),
        'rss.xml'   => array('keyValues' => array ('type' => 100,),),
        'atom.xml'   => array('keyValues' => array ('type' => 103,),),
        'sitemap.xml'   => array('keyValues' => array ('type' => 776,),),
        'manifest.json'   => array('keyValues' => array ('type' => 850,),),
        ),
    ),
    'fixedPostVars' => array(
    ),
    'postVarSets' => array(
    ),
);