[TYPO3] RealUrl, multidomain, multilanguage, single tree setup 2

Dmitriy Osadchiy dmi3 at clarity.kiev.ua
Wed Dec 26 09:52:09 CET 2007


Hello Tomi,

Thanks for the configuration example. I need same solution. So I have 
configured as you describe and it works, but with a problem: I have "L" 
variable as request parameter.

My situation is German (0), English (1) and Chinese (2).
According domains are domain.de, domain.com, domain.cn
For chinese urls I am using "p2_realurl" extension (this makes chinese 
uls in english).

So as I have described I have
domain.de/de_file.html
domain.com/en_file.html?L=1
domain.cn/en_file.html?L=2

Any hints?

My TypoScript:
# ============================
page.config {
   linkVars = L
   uniqueLinkVars = 1
#  prefixLocalAnchors = all
   tx_realurl_enable = 1
}

page.config.sys_language_uid = 0
page.config.language = de
page.config.htmlTag_langKey = de
page.config.locale_all = de_DE.utf8

[globalString = IENV:HTTP_HOST = domain.de]
   page.config.baseURL = http://domain.de/

[globalString = IENV:HTTP_HOST = domain.com]
   page.config.baseURL = http://domain.com/
   page.config.sys_language_uid = 1
   page.config.language = en
   page.config.htmlTag_langKey = en
   page.config.locale_all = en_EN.utf8

[globalString = IENV:HTTP_HOST = domain.cn]
   page.config.baseURL = http://domain.cn/
   page.config.sys_language_uid = 2
   page.config.language = ch
   page.config.htmlTag_langKey = zh-CN
   page.config.locale_all = zh_CN.utf8
   page.config.language_alt = en
   page.config.sys_language_mode = content_fallback ; 1,0
# ============================


End of localconf.php

if(preg_match('/domain\.com/', $_SERVER["HTTP_HOST"])) {
     $_GET['L'] = 1;
} elseif(preg_match('/domain\.cn/', $_SERVER["HTTP_HOST"])) {
     $_GET['L'] = 2;
} // else $_GET['L'] is not set, so it's default language


Part of RealURL configuration:

$TYPO3_CONF_VARS['EXTCONF']['realurl']['domain.de'] = array (
         'init' => array (
             'enableCHashCache' => '1',
             'appendMissingSlash' => 'ifNotFile',
             'respectSimulateStaticURLs' => '1',
             'enableUrlDecodeCache' => '1',
             'enableUrlEncodeCache' => '1',
             'emptyUrlReturnValue' => 'http://domain.de/',
             'rootPageId' => 2,
         ), // init section close
....
         'preVars' => array (
             '0' => array (
                 'GETvar' => 'no_cache',
                 'valueMap' => array (
                     'nc' => '1',
                 ),
                 'noMatch' => 'bypass'
             ),
         ), // preVars section close
....
         'pagePath' => array (
             'type' => 'user',
             'userFunc' => 
'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
             'spaceCharacter' => '-',
             'languageGetVar' => 'L',
             'expireDays' => '60',
             'rootpage_id' => '2',
	    'disablePathCache' => false,
	    'autoUpdatePathCache' => false,
         ), // pagePath section close
....
     );


$TYPO3_CONF_VARS['EXTCONF']['realurl']['domain.com'] = 
$TYPO3_CONF_VARS['EXTCONF']['realurl']['domain.de'];

$TYPO3_CONF_VARS['EXTCONF']['realurl']['domain.com']['preVars'][1] = array(
	'GETVar' => 'L',
	    'valueMap' =>
		array(
		    'dummy' => 111,
		),
	    'noMatch' => 'bypass',
);

$TYPO3_CONF_VARS['EXTCONF']['realurl']['domain.cn'] = 
$TYPO3_CONF_VARS['EXTCONF']['realurl']['domain.com'];

$TYPO3_CONF_VARS['EXTCONF']['realurl']['domain.cn']['init']['emptyUrlReturnValue'] 
= 'domain.cn';

$TYPO3_CONF_VARS['EXTCONF']['realurl']['domain.cn']['preVars'][1] = array(
	'GETVar' => 'L',
	    'valueMap' =>
		array(
		    'dummy' => 112,
		),
	    'noMatch' => 'bypass',
);



Tomi Hrovatin wrote:
> Tomas, you're the man!
> 
> That did the trick. Thank you all for your answers.
> 
> Here is the 'working' setup for realurl, multidomain, multilanguage, 
> singletree setup. :)
> Note that there is also a little trick to get rid of backpid and chash 
> in tt_products (thanks to Xxtobi from typo3.net)
> 
> ***************************************
> Realurl localconf.php setup (you can put this in realurl_autoconf.php as 
> well):
> ***************************************
> 
> $TYPO3_CONF_VARS['EXTCONF']['realurl']['www.eksotika.si'] = array(
>     'init' => array (
>         'enableCHashCache' => 1,
>         'appendMissingSlash' => 'ifNotFile',
> //          'adminJumpToBackend' => true,
>           'rootPageID' =>  2,
>         'enableUrlDecodeCache' => true,
>         'enableUrlEncodeCache' => true,
>             'emptyUrlReturnValue' => true,
>     ),
> 
>     'redirects' => array (
>     ),
> 
>     'pagePath' => array (
>         'type' => 'user',
>         'userFunc' => 
> 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
>         'spaceCharacter' => '-',
>         'languageGetVar' => 'L',
>         'expireDays' => 3,
>         'rootpage_id' => 2,
>     ),
>     'fixedPostVars' => array(),
>     'postVarSets' => array(
>         '_DEFAULT' => array(
>             //tt_news
>             // archive
>             'p' => array(
>                 array(
>                     'condPrevValue' => -1,
>                     'GETvar' => 'tx_ttnews[pS]' ,
>                     'valueMap' => array(
>                     )
>                 ),
>                 array(
>                     'GETvar' => 'tx_ttnews[pL]' ,
>                     'valueMap' => array(
>                     )
>                 ),
>                 array(
>                     'GETvar' => 'tx_ttnews[arc]' ,
>                     'valueMap' => array(
>                         'archived' => 1,
>                         'non-archived' => -1,
>                     )
>                 ),
>             ),
>             // pagebrowser
>             'pb' => array(
>                 array(
>                     'GETvar' => 'tx_ttnews[pointer]',
>                 ),
>             ),
>                 // category
>             's' => array (
>                 array(
>                     'GETvar' => 'tx_ttnews[cat]',
>                     'lookUpTable' => array(
>                         'table' => 'tt_news_cat',
>                         'id_field' => 'uid',
>                         'alias_field' => 'title',
>                         'addWhereClause' => ' AND NOT deleted',
>                         'useUniqueCache' => 1,
>                         'useUniqueCache_conf' => array(
>                             'strtolower' => 1,
>                         ),
>                     ),
>                 ),
>             ),
>                 // news item
>             'rastline' => array(
>                 array(
>                     'GETvar' => 'tx_ttnews[backPid]',
>                 ),
>                 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' => '-',
>                         ),
>                     ),
>                 ),
>                 array(
>                     'GETvar' => 'tx_ttnews[swords]'
>                 ),
>             ),
> // products
> 'rastlina' => array(
>         array(
>                 'GETvar' => 'tx_ttproducts_pi1[product]',
>                 'lookUpTable' => array(
>                         'table' => 'tt_products',
>                         'id_field' => 'uid',
>                         'alias_field' => 'title',
>                         'addWhereClause' => ' AND NOT deleted',
>                         'useUniqueCache' => 1,
>                         'useUniqueCache_conf' => array(
>                                 'strtolower' => 1,
>                                 'spaceCharacter' => '-',
>                         ),
>                 ),
>         ),
>             array (
>            'GETvar' => 'tx_ttproducts_pi1[backPID]',
>            'valueMap' => array(
>                 'dummy' => '1',
>            ),
>            'noMatch' => 'null',
>         ),
> ),
>         ),
>     ),
>        'fileName' => array (
> 
>             'defaultToHTMLsuffixOnPrev' => true,
>             'index' => array (
>                 'rss.xml' => array (
>                     'keyValues' => array (
>                         'type' => '100',
>                     ),
>                 ),
>                 'rss091.xml' => array (
>                     'keyValues' => array (
>                         'type' => '101',
>                     ),
>                 ),
>                 'rdf.xml' => array (
>                     'keyValues' => array (
>                         'type' => '102',
>                     ),
>                 ),
>                 'atom.xml' => array (
>                     'keyValues' => array (
>                         'type' => '103',
>                     ),
>                 ),
>             ),
>         ),
> );
> $TYPO3_CONF_VARS['EXTCONF']['realurl']['www.rare-exotic-plants.com'] = 
> $TYPO3_CONF_VARS['EXTCONF']['realurl']['www.eksotika.si'];
> $TYPO3_CONF_VARS['EXTCONF']['realurl']['www.rare-exotic-plants.com']['postVarSets']['_DEFAULT'] 
> = array(
>             //tt_news
>             // archive
>             'p' => array(
>                 array(
>                     'condPrevValue' => -1,
>                     'GETvar' => 'tx_ttnews[pS]' ,
>                     'valueMap' => array(
>                     )
>                 ),
>                 array(
>                     'GETvar' => 'tx_ttnews[pL]' ,
>                     'valueMap' => array(
>                     )
>                 ),
>                 array(
>                     'GETvar' => 'tx_ttnews[arc]' ,
>                     'valueMap' => array(
>                         'archived' => 1,
>                         'non-archived' => -1,
>                     )
>                 ),
>             ),
>             // pagebrowser
>             'pb' => array(
>                 array(
>                     'GETvar' => 'tx_ttnews[pointer]',
>                 ),
>             ),
>                 // category
>             's' => array (
>                 array(
>                     'GETvar' => 'tx_ttnews[cat]',
>                     'lookUpTable' => array(
>                         'table' => 'tt_news_cat',
>                         'id_field' => 'uid',
>                         'alias_field' => 'title',
>                         'addWhereClause' => ' AND NOT deleted',
>                         'useUniqueCache' => 1,
>                         'useUniqueCache_conf' => array(
>                             'strtolower' => 1,
>                         ),
>                     ),
>                 ),
>             ),
>                 // news item
>             'plants' => array(
>                 array(
>                     'GETvar' => 'tx_ttnews[backPid]',
>                 ),
>                 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' => '-',
>                         ),
>                     ),
>                 ),
>                 array(
>                     'GETvar' => 'tx_ttnews[swords]'
>                 ),
>             ),
> 
> 
> 
> 
> 'plant' => array(
>         array(
>                 'GETvar' => 'tx_ttproducts_pi1[product]',
>                 'lookUpTable' => array(
>                         'table' => 'tt_products',
>                         'id_field' => 'uid',
>                         'alias_field' => 'title',
>                         'addWhereClause' => ' AND NOT deleted',
>                         'useUniqueCache' => 1,
>                         'useUniqueCache_conf' => array(
>                                 'strtolower' => 1,
>                                 'spaceCharacter' => '-',
>                         ),
>                 ),
>         ),
>             array (
>            'GETvar' => 'tx_ttproducts_pi1[backPID]',
>            'valueMap' => array(
>                 'dummy' => '1',
>            ),
>            'noMatch' => 'bypass',
>         ),
> ),
> );
> $TYPO3_CONF_VARS['EXTCONF']['realurl']['www.rare-exotic-plants.com']['preVars'] 
> = array (
>                 array (
>                   'GETvar' => 'L',
>                       'valueMap' =>
>                             array (
>                                 'dummy' => '10',
>                      ),
>                             'noMatch' => 'bypass',
>                 ),
> );
> 
> ***************************************
> Put this at the end of localconf.php:
> ***************************************
> 
> if(preg_match('/rare-exotic-plants\.com/', $_SERVER["HTTP_HOST"])) {
>   $_GET['L'] = 1;
> //} else if(preg_match('/german_domain\.de/', $_SERVER["HTTP_HOST"])) {
> //  $_GET['L'] = 2;
> } // else $_GET['L'] is not set, so it's default, Slovenian
> 
> ***************************************
> Typoscript setup:
> ***************************************
> 
> # TS for languages
> 
> config.linkVars = L
> config.uniqueLinkVars = 1
> 
> [globalString = IENV:HTTP_HOST = *eksotika.si]
> config {
>   language=si
>   sys_language_uid = 0
>   locale_all = sl_SI
>   htmlTag_langKey = si
> }
> [end]
> [globalString = IENV:HTTP_HOST = *rare-exotic-plants.com]
> config {
>   language=en
>   sys_language_uid = 1
>   locale_all = en_US
>   htmlTag_langKey = en
> }
> [end]
> [global]
> 
> ############# enable realUrl *********************
> config.simulateStaticDocuments = 0
> config.baseURL = {$website.baseUrl} # change this to current domain
> config.tx_realurl_enable = 1
> config.prefixLocalAnchors = all
> 
> 
> That's it.
> 
> thanks again,
> Tomi Hrovatin
> 
> 
> Tomas Mrozek wrote:
>> 1. If your site is showing different language content despite the 
>> TypoScript condition then your problem is in your TypoScript setup and 
>> it wouldn't work even without RealURL, as Dmitry pointed out.
>>
>> 2. You don't want preVars in your URLs since you want to choose 
>> language according to domain, not the preVar. Therefore, there's no 
>> need to definy preVars for RealURL in the localconf.php.
>>
>> 3. You most probably need to have set $_GET['L']. Otherwise, RealURL 
>> will create links from page titles of default language. Therefore, 
>> SOMETHING must set the variable.
>> I am not sure what would be a good approach. I used to solve it by 
>> adding folowing to the localconf.php:
>>
>> if(preg_match('/english_domain\.com/', $_SERVER["HTTP_HOST"])) {
>>   $_GET['L'] = 1;
>> } else if(preg_match('/german_domain\.de/', $_SERVER["HTTP_HOST"])) {
>>   $_GET['L'] = 2;
>> } // else $_GET['L'] is not set, so it's default, Slovenian
>>
>> Tomas Mrozek


More information about the TYPO3-english mailing list