tt_news:在单个视图中更改语言时没有给出news_id

时间:2012-02-09 14:42:55

标签: typo3 realurl tt-news

我正在使用TYP 4.5.5,RealURL 1.11.2和tt_news 3.0.1。我希望用户可以切换语言,相应的新闻以用户语言显示。所有这些都应该与RealURL一起使用。

切换语言时,不提交新闻ID。所以我必须明确提交id。我找到了一些线程,告诉我它是如何工作的,但我没有得到它的管理。这是我的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>
  )

根据我发现的信息,我应该使用additionalParams并使用GPVar设置参数。但我总是收到no news_id given消息。

这是我的RealURL配置:

$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]',
                    ),
                ),
            ),
        ),

解决方案:

似乎添加addQueryString可以胜任这项工作。这是我的最终语言切换器:

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

2 个答案:

答案 0 :(得分:4)

查看菜单的以下属性:

protectLvar

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

TSREF是你的朋友: http://typo3.org/documentation/document-library/core-documentation/doc_core_tsref/4.6.0/view/1/7/#id2635691

答案 1 :(得分:1)

你的TypoScript有一些错误:

20.wrap = &tx_tt_news[tt_news]=|

删除下划线:

20.wrap = &tx_ttnews[tt_news]=|

不要手动设置cHash! 30.wrap = &cHash=|它会阻止您的网页被缓存,因为cHash会出错!