Question

I'm using TYP 4.5.5, RealURL 1.11.2 and tt_news 3.0.1. I want that the user can switch the language and the corresponding news is shown in the users language. All should work with RealURL.

When switching language the news id is not submitted. So I have to explicitely submit the id. I found some threads which showed me how it could work, but I didn't get it managed. Here is my TS:

lib.tslangmenu = COA
lib.tslangmenu {
  10 = HTML
  10.value(
    <img src="fileadmin/templates/images/languages_en.png" width="48" height="121" alt="Languages" />
    <div id="LanguageContents">
  )

  20 = HMENU
  20.special = language
  20.wrap = <div id="AvailableLanguages">|</div>
  20.special.value = 0,1
  20.1 = GMENU
  20.1.NO {
    XY = 24,16
    5 = IMAGE
    5.file = fileadmin/templates/images/deutsch.png || fileadmin/templates/images/englisch.png
    additionalParams.cObject = COA
    additionalParams.cObject {
      5 = TEXT
      5.wrap = &L=1 

      10 = TEXT
      10.data = GPvar : tx_ttnews | backPid
      10.wrap = &tx_ttnews[backPid]=|
      10.required = 1

      20 = TEXT
      20.data = GPvar : tx_ttnews | tt_news
      20.wrap = &tx_tt_news[tt_news]=|
      20.required = 1

      30 = TEXT
      30.data = GPvar : cHash
      30.wrap = &cHash=|
      30.required = 1
    } 
  }

  30 = HTML
  30.value(
    <img class="languagebutton" src="fileadmin/templates/images/languages_en.png" width="48" height="121" alt="Languages" />
    </div>
  )

According to the information I found I should use additionalParams and set the parameter with GPVar. But I always get the no news_id given message.

Here is my RealURL Config:

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array ( 
    '_DEFAULT' => array (
        'init' => array (
            'enableCHashCache' => '1',
            'appendMissingSlash' => 'ifNotFile',
            'enableUrlDecodeCache' => '1',
            'enableUrlEncodeCache' => '1',
        ),
        'redirects' => array (
        ),
        'preVars' => array (
            '0' => array (
                'GETvar' => 'no_cache',
                'valueMap' => array (
                    'nc' => '1',
                ),
                'noMatch' => 'bypass'
            ),
            '1' => array (
                'GETvar' => 'L',
                'valueMap' => array (
                    'de' => '0',
                    'en' => '1',
                ),
                'valueDefault' => 'de',
                'noMatch' => 'bypass',
            ),
            '2' => array (
                'GETvar' => 'lang',
                'valueMap' => array (
                    'de' => 'de',
                    'en' => 'en',
                ),
                'noMatch' => 'bypass',
            ),
        ),
        'pagePath' => array (
            'type' => 'user',
            'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'expireDays' => '7',
            'rootpage_id' => '1',
        ),
        'fixedPostVars' => array (
        ),
        'postVarSets' => array (
            '_DEFAULT' => array (
                'archive' => array (
                    '0' => array (
                        'GETvar' => 'tx_ttnews[year]',
                    ),
                    '1' => array (
                        'GETvar' => 'tx_ttnews[month]',
                        'valueMap' => array (
                            'january' => '01',
                            'february' => '02',
                            'march' => '03',
                            'april' => '04',
                            'may' => '05',
                            'june' => '06',
                            'july' => '07',
                            'august' => '08',
                            'september' => '09',
                            'october' => '10',
                            'november' => '11',
                            'december' => '12',
                        ),
                    ),
                ),
                'browse' => array (
                    '0' => array (
                        'GETvar' => 'tx_ttnews[pointer]',
                    ),
                ),
                'select_category' => array (
                    '0' => array (
                        'GETvar' => 'tx_ttnews[cat]',
                    ),
                ),
                'article' => array(
                    array(
                        'GETvar' => 'tx_ttnews[pointer]',
                        'valueMap' => array(),
                        'noMatch' => 'bypass',
                    ),
                    array(
                        'GETvar' => 'tx_ttnews[tt_news]',
                        'lookUpTable' => array(
                            'table' => 'tt_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' => 'l18n_parent',
                            'autoUpdate' => 1,
                            'expireDays' => 180,
                        ),
                    ),
                    array (
                        'GETvar' => 'tx_ttnews[swords]',
                    ),
                ),
            ),
        ),

Solution:

Seems that adding addQueryString does the job. Here is my final language switcher:

lib.tslangmenu = COA
lib.tslangmenu {
  10 = HTML
  10.value(
    <img src="fileadmin/templates/images/languages.png" width="48" height="121" alt="Sprachen" />
    <div id="LanguageContents">
  )

  20 = HMENU
  20.special = language
  20.wrap = <div id="AvailableLanguages">|</div>
  20.special.value = 0,1
  20.addQueryString = 1
  20.1 = GMENU
  20.1.NO {
    XY = 24,16
    5 = IMAGE
    5.file = fileadmin/templates/images/deutsch.png || fileadmin/templates/images/englisch.png || fileadmin/templates/images/kroatisch.png 
  }

  20.1.ACT < 20.1.NO
  20.1.ACT = 1
  20.1.ACT.wrap =<span class="langhide">|</span> 
  20.1.ACT {
    XY = 24,16
    5 = IMAGE
    5.file = fileadmin/templates/images/deutsch.png || fileadmin/templates/images/englisch.png || fileadmin/templates/images/kroatisch.png 
  }

  20.1.CUR < 20.1.ACT
  20.1.CUR = 1
  20.1.CUR{
    XY = 24,16
    5 = IMAGE
    5.file = fileadmin/templates/images/deutsch.png || fileadmin/templates/images/englisch.png || fileadmin/templates/images/kroatisch.png 
  }

  30 = HTML
  30.value(
    <img class="languagebutton" src="fileadmin/templates/images/languages.png" width="48" height="121" alt="Sprachen" />
    </div>
  )
}
Was it helpful?

Solution

Take a look at the following properties for your menu:

protectLvar

addQueryString <--- keeps the params to the string when switching languages.

TSREF is your friend: http://typo3.org/documentation/document-library/core-documentation/doc_core_tsref/4.6.0/view/1/7/#id2635691

OTHER TIPS

Your TypoScript has some errors:

20.wrap = &tx_tt_news[tt_news]=|

Remove tthe underscore:

20.wrap = &tx_ttnews[tt_news]=|

And do not set cHash by hand! 30.wrap = &cHash=| It will prevent your page from being cached, because the cHash will be wrong!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top