ǝlpoodooɟƃuooʞ
ǝlpoodooɟƃuooʞ

Reputation: 516

typo3 get rid of default language parameter in URL

I have a multilingual TYPO3 Website with RealURL. German is the default (and fallback) language, English is the translation. I want to get rid of the GET Parameter ?L=0 for the default language in the language menu. How to do it?

#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>
    }

}

Upvotes: 0

Views: 2016

Answers (2)

Scopestyle
Scopestyle

Reputation: 665

The solution:

I had the exact same problem, this is how I fixed it by checking the following steps:

  1. Update RealURL to the latest version (2.4.0 at time of writing).
  2. Read the documentation and make sure your configuration is correct.

This is the code I ended up with, in my configuration the problem where the language parameter shows in the language menu no longer exists.

Language Menu Typoscript:

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
    }
}

Basic RealURL Configuration:

<?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(
    ),
);

Upvotes: 1

Ralf Merz
Ralf Merz

Reputation: 111

your lines 4 - 7 are missing config. prefix. I would define config.linkVars = L(0,1)

And here is a language menu example for 3 languages: 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 >
         }

     }
   }
}

I have to say that we build URL paths with language segment also in default language. So for DE URLs we have sth. like my-domain.tld/de/your/path/ But setting no default in TSsetup and in realurl config should give you default URLs without the default language in path.

Hope that helps.

Upvotes: 1

Related Questions