在Typoscript HMENU中,如何强制URL的语言

时间:2015-02-11 21:14:03

标签: typo3 typoscript realurl typo3-4.5

我有一个多语言,多站点,多域的TYPO3(4.5)实例,其中RealURL让我忙碌。在某些子站点中,我无法让它为语言1和2创建正确的URL。

这将导致模式www.language-2-domain.com/language-1-pagetitle

我想知道是否/如何告诉TMENU强制使用某种语言,而不是继续摆弄realurl_conf,然后我可以用条件来解决它。

这是一个完全正常的TMENU:

lib.content_sitemap = COA
lib.content_sitemap {
5 = HMENU
5 {
  wrap = <ul>|</ul>
  1 = TMENU
  1 {
    expAll = 1
    noBlur = 1
    NO {
       wrapItemAndSub = <li>|</li>
       text = nav_title // title
     }

   ACT < .NO
   ACT {
       wrapItemAndSub = <li>|</li>
       }
   ACT = 1

   CUR < .NO
   CUR {
       wrapItemAndSub = <li>|</li>
       }
   CUR = 1
    }
  }
}

现在我可以使用的是

5.1.NO.text.sys_language_uid = 1

有类似的东西吗?

编辑:我知道,这不是关注的“文本”。我可以用“doNotLinkIt”手动构建一个typolink,并强制语言在那里吗?

1 个答案:

答案 0 :(得分:0)

这是一个明显的例子,“在一夜好眠之后,绝望并寻找黑客而不是看问题。”

RealURL配置中存在不一致,这引起了错误的行为。

我发布了希望完全正常工作的RealURL配置。 它涵盖两个单域/多语言网站以及两个多域/多语言网站。这就是我在网址上使用regex的原因。

 <?php
 $TYPO3_CONF_VARS['EXTCONF']['realurl'] = array (
    '_DEFAULT' => array (
        'init' => array(
            'enableCHashCache' => 1,
            'respectSimulateStaticURLs' => 0,
            'appendMissingSlash' => 'ifNotFile',
            'enableUrlDecodeCache' => 1,
            'enableUrlEncodeCache' => 1,
        ),
        'preVars' => array(
            array(
                 'GETvar' => 'L',
                 'valueMap' => array(
                                    'de' => '0',
                                    'fr' => '1',
                                    'it' => '2',
                            ),
                 'valueDefault' => 'de',
                 'noMatch' => 'bypass',
            ),
            array(
                'GETvar' => 'no_cache',
                'valueMap' => array(
                    'no_cache' => 1,
                ),
                'noMatch' => 'bypass',
            ),
        ),
        'pagePath' => array (
            'rootpage_id' => 1,
            'type' => 'user',
            'disablePathCache' => 0,
            'userFunc' =>
            'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'expireDays' => 3
        ),
        'fileName' => array(
            'defaultToHTMLsuffixOnPrev' => 0,
        ),
    ),
);

/* site1 and site2 are single-domain */

/* site3 */
# http://blog.teamgeist-medien.de/2013/09/hardcore-realurl-mehrere-domains-prevars-sprachen-rootpages-decodeencode.html

if (    preg_match('/(www\.)?site3-d\.ch/', $_SERVER['HTTP_HOST']) > 0 
    ||  preg_match('/(www\.)?site3-f\.ch/', $_SERVER['HTTP_HOST']) > 0 
    ||  preg_match('/(www\.)?site3-i\.ch/', $_SERVER['HTTP_HOST']) > 0 ) {

$TYPO3_CONF_VARS['EXTCONF']['realurl']['site3'] = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];
$TYPO3_CONF_VARS['EXTCONF']['realurl']['site3']['pagePath']['rootpage_id'] = '618';

$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DOMAINS'] = array(
    'encode' => array(
        array(
            'GETvar' => 'L',
            'value' => '',
            'useConfiguration' => 'site3',
            'urlPrepend' => 'http://www.site3-d.ch',
        ),
        array(
            'GETvar' => 'L',
            'value' => '0',
            'useConfiguration' => 'site3',
            'urlPrepend' => 'http://www.site3-d.ch',
        ),
        array(
            'GETvar' => 'L',
            'value' => '1',
            'useConfiguration' => 'site3',
            'urlPrepend' => 'http://www.site3-f.ch'
        ),
        array(
            'GETvar' => 'L',
            'value' => '2',
            'useConfiguration' => 'site3',
            'urlPrepend' => 'http://www.site3-i.ch',
        ),
    ),
    'decode' => array(
        'www.site3-d.ch' => array(
            'GETvars' => array(
                'L' => '0',
            ),
            'useConfiguration' => 'site3',
        ),
        'www.site3-f.ch' => array(
            'GETvars' => array(
                'L' => '1',
            ),
            'useConfiguration' => 'site3',
        ),
        'www.site3-i.ch' => array(
            'GETvars' => array(
                'L' => '2',
            ),
            'useConfiguration' => 'site3',
        ),
    ),
);
}

/**      site4    */

if (    preg_match('/(www\.)?site4-d\.ch/', $_SERVER['HTTP_HOST']) > 0 
    ||  preg_match('/(www\.)?site4-f\.ch/', $_SERVER['HTTP_HOST']) > 0 ) {

// default Konfiguration übernehmen
$TYPO3_CONF_VARS['EXTCONF']['realurl']['site4'] = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];
$TYPO3_CONF_VARS['EXTCONF']['realurl']['site4']['pagePath']['rootpage_id'] = '574';
$TYPO3_CONF_VARS['EXTCONF']['realurl']['site4']['preVars'] = array();

$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DOMAINS'] = array(
    'encode' => array(
        array(
            'GETvar' => 'L',
            'value' => '',
            'useConfiguration' => 'site4',
            'urlPrepend' => 'http://www.site4-d.ch',
        ),
        array(
            'GETvar' => 'L',
            'value' => '0',
            'useConfiguration' => 'site4',
            'urlPrepend' => 'http://www.site4-d.ch',
        ),
        array(
            'GETvar' => 'L',
            'value' => '1',
            'useConfiguration' => 'site4',
            'urlPrepend' => 'http://www.site4-f.ch'
        ),
    ),
    'decode' => array(
        'www.site4-d.ch' => array(
            'GETvars' => array(
                'L' => '0',
            ),
            'useConfiguration' => 'site4',
        ),
        'www.site4-f.ch' => array(
            'GETvars' => array(
                'L' => '1',
            ),
            'useConfiguration' => 'site4',
        ),
    ),
);
}


?>