Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Realurl配置域与语言的get参数的组合_Php_Typo3_Realurl_Multiple Languages - Fatal编程技术网

Php Realurl配置域与语言的get参数的组合

Php Realurl配置域与语言的get参数的组合,php,typo3,realurl,multiple-languages,Php,Typo3,Realurl,Multiple Languages,英豪 我有一个TYPO3网站,每个语言都有很多翻译 如果用户有特定的域,那么用于翻译的Realurl配置工作正常。例如domainname.com、domainname.de、domainname.es等等 现在我想添加一个新的翻译(葡萄牙语),但我没有它的域名。我想使用url domainname.com/pt进行新的翻译 RealUrl支持这种不同的使用方式吗 后端中的预览无法正常工作。 langauge菜单包含一个正确的链接,但打开它时,我会得到标准的langauge(en) 在TS中:

英豪

我有一个TYPO3网站,每个语言都有很多翻译

如果用户有特定的域,那么用于翻译的Realurl配置工作正常。例如domainname.com、domainname.de、domainname.es等等

现在我想添加一个新的翻译(葡萄牙语),但我没有它的域名。我想使用url domainname.com/pt进行新的翻译

RealUrl支持这种不同的使用方式吗

后端中的预览无法正常工作。 langauge菜单包含一个正确的链接,但打开它时,我会得到标准的langauge(en)

在TS中:

configname {
    baseURL = https://www.domainname.com
    sys_language_uid = 0
    language = en
    locale_all = en_EN
    htmlTag_langKey = en
}

[globalVar = GP:L = 0]
configname {
    sys_language_uid = 0
    language = en
    locale_all = en_EN
    htmlTag_langKey = en
}
[global]

[globalVar = GP:L = 1]
configname {
    sys_language_uid = 1
    language = de
    locale_all = de_DE
    htmlTag_langKey = de
    baseURL = https://www.domainname.de
}
[global]

....

#new config for portuguese
[globalVar = GP:L = 3]
    configname {
        sys_language_uid = 3
        language = pt
        locale_all = pt_PT
        htmlTag_langKey = pt
    }
[global]
也许我不知道如何为此正确配置realurl_conf.php

来了:

$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array(
'preVars' => array(
    array(
        'GETvar' => 'L',
        'valueMap' => array(
            'pt' => '3',
        ),
        'valueDefault' => '',
        'noMatch' => 'bypass',
    ),
),
....
);

$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DOMAINS'] = array(
'encode' => array(
    array(
        'GETvar' => 'L',
        'value' => '',
        'ifDifferentToCurrent' => true,
        'useConfiguration' => '_DEFAULT',
        'urlPrepend' => 'https://www.domainname.com',
    ),
    array(
        'GETvar' => 'L',
        'value' => '0',
        'ifDifferentToCurrent' => true,
        'useConfiguration' => '_DEFAULT',
        'urlPrepend' => 'https://www.domainname.com'
    ),
    array(
        'GETvar' => 'L',
        'value' => '1',
        'ifDifferentToCurrent' => true,
        'useConfiguration' => '_DEFAULT',
        'urlPrepend' => 'https://www.domainname.de'
    ),

    array(
        'GETvar' => 'L',
        'value' => '2',
        'ifDifferentToCurrent' => true,
        'useConfiguration' => '_DEFAULT',
        'urlPrepend' => 'https://www.domainname.es'
    ),

    array(
        'GETvar' => 'L',
        'value' => '4',
        'ifDifferentToCurrent' => true,
        'useConfiguration' => '_DEFAULT',
        'urlPrepend' => 'https://www.domainname.cn'
    ),

    array(
        'GETvar' => 'L',
        'value' => '6',
        'ifDifferentToCurrent' => true,
        'useConfiguration' => '_DEFAULT',
        'urlPrepend' => 'https://www.domainname.com'
    ),

),

'decode' => array(
    'www.domainname.com' => array(
        'GETvars' => array(
            'L' => '0',
        ),
        'useConfiguration' => '_DEFAULT',
    ),

    'www.domainname.de' => array(
        'GETvars' => array(
            'L' => '1',
        ),
        'useConfiguration' => '_DEFAULT'
    ),

    'www.domainname.es' => array(
        'GETvars' => array(
            'L' => '2',
        ),
        'useConfiguration' => '_DEFAULT'
    ),

    'www.domainname.cn' => array(
        'GETvars' => array(
            'L' => '4',
        ),
        'useConfiguration' => '_DEFAULT'
    ),
   ),
);

如何说realurl是它必须使用的语言3,有什么建议吗?

MultiLanguage/Multidomain config很容易实现。。。 不过,我从来没有混合过不同的模式

我第一眼看到的最大问题 您的所有域配置都使用相同的[\u default]配置吗- 我始终为每个域创建专用阵列,如下所示:

// [_default] stuff

$TYPO3_CONF_VARS['EXTCONF']['realurl']['whatever.de']  = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];
$TYPO3_CONF_VARS['EXTCONF']['realurl']['whatever.de']['pagePath']['rootpage_id'] = 1;
$TYPO3_CONF_VARS['EXTCONF']['realurl']['whatever.com']  = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];
$TYPO3_CONF_VARS['EXTCONF']['realurl']['whatever.com']['pagePath']['rootpage_id'] = 1;

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DOMAINS']['encode'] = array(
    array(
        'GETvar' => 'L',
        'value' => '0',
        'useConfiguration' => 'whatever.de',
        'urlPrepend' => 'http://whatever.de',
        'ifDifferentToCurrent' => true,
    ),
    array(
        'GETvar' => 'L',
        'value' => '1',
        'useConfiguration' => 'whatever.com',
        'urlPrepend' => 'http://whatever.com',
        'ifDifferentToCurrent' => true,
    ),
// ...
);

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DOMAINS']['decode'] = array(
    'whatever.de' => array(
        'GETvars' => array(
            'L' => '0',
        ),
        'useConfiguration' => 'whatever.de'
    ),
    'whatever.com' => array(
        'GETvars' => array(
            'L' => '1',
        ),
        'useConfiguration' => 'whatever.com'
    ),
// ...
);
但最干净的解决方案肯定是获得必要的.pt域,imho

现在我想添加一个新的翻译(葡萄牙语),但我没有它的域名。我想使用url domainname.com/pt进行新的翻译

RealUrl支持这种不同的使用方式吗


不,没有。它可以是域,也可以是语言段。

谢谢你们的回答

我找到了解决办法。这是所有的abput编码/解码块和前置。此外,我还将自己连接到UrlDecoder(函数setRequestVariables(){…})中,专门用于我的目的(脏修复)。 一个配置就足以实现真正的url工作,以混合多域和语言参数

realurl_conf.php

$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array(
    'init' => array(
        'enableCHashCache' => true,
        'appendMissingSlash' => 'ifNotFile',
        'enableUrlDecodeCache' => true,
        'emptyUrlReturnValue' => '/',
    ),
    'preVars' => array(
        array(
            'GETvar' => 'L',
            'valueMap' => array(
                'en' => '0',
                'de' => '1',
                'es' => '2',
                'pt' => '3',
                'cn' => '4',
                'it' => '5',
                'us' => '6',
                'fr' => '7',
            ),
            'valueDefault' => 'en',
            'noMatch' => 'bypass',
        ),
    ),
    ...
);
现在结束代码/解码块:

$TYPO3_CONF_VARS['EXTCONF']['realurl']['example.org'] = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DOMAINS'] = array(
    'encode' => array(
        array(
            'GETvar' => 'L',
            'value' => '0',
            'useConfiguration' => 'example.org',
            'urlPrepend' => 'https://www.example.org'
        ),
        array(
            'GETvar' => 'L',
            'value' => '1',
            'useConfiguration' => 'example.org',
            'urlPrepend' => 'https://www.example.de'
        ),
        array(
            'GETvar' => 'L',
            'value' => '2',
            'useConfiguration' => 'example.org',
            'urlPrepend' => 'https://www.example.es'
        ),
        array(
            'GETvar' => 'L',
            'value' => '3',
            'useConfiguration' => 'example.org',
            'urlPrepend' => 'https://www.example.org/pt'
        ),
        array(
            'GETvar' => 'L',
            'value' => '4',
            'useConfiguration' => 'example.org',
            'urlPrepend' => 'https://www.example.cn'
        ),
        array(
            'GETvar' => 'L',
            'value' => '6',
            'useConfiguration' => 'example.org',
            'urlPrepend' => 'https://www.example.org/us'
        ),
        array(
            'GETvar' => 'L',
            'value' => '7',
            'useConfiguration' => 'example.org',
            'urlPrepend' => 'https://www.example.org/fr'
        )
    ),

    'decode' => array(
        'example.com' => array(
            'GETvars' => array(
                'L' => '0',
            ),
            'useConfiguration' => 'example.org'
        ),
        'example.de' => array(
            'GETvars' => array(
                'L' => '1',
            ),
            'useConfiguration' => 'example.org'
        ),
        'example.es' => array(
            'GETvars' => array(
                'L' => '2',
            ),
            'useConfiguration' => 'example.org'
        ),
        'example.pt' => array(
            'GETvars' => array(
                'L' => '3',
            ),
            'useConfiguration' => 'example.org'
        ),
        'example.cn' => array(
            'GETvars' => array(
                'L' => '4',
            ),
            'useConfiguration' => 'example.org'
        ),
        'example.us' => array(
            'GETvars' => array(
                'L' => '6',
            ),
            'useConfiguration' => 'example.org'
        ),
        'example.fr' => array(
            'GETvars' => array(
                'L' => '7',
            ),
            'useConfiguration' => 'example.org'
        )
    )
);
realUrlDecoder.php

use DmitryDulepov\Realurl\Cache\UrlCacheEntry;
class RealurlUrlDecoder extends \DmitryDulepov\Realurl\Decoder\UrlDecoder {


    /**
     * Sets variables after the decoding.
     *
     * @param UrlCacheEntry $cacheEntry
     */
    public function setRequestVariables(UrlCacheEntry $cacheEntry) {

        $languageWithoutDomain = array(
            3 => '/pt/',
            6 => '/us/',
            7 => '/fr/',
        );

        if (in_array(substr($_SERVER['REQUEST_URI'], 0, 4), $languageWithoutDomain)) {
            foreach ($languageWithoutDomain as $key => $value) {
                 if(substr($_SERVER['REQUEST_URI'], 0, 4) == $value){
                    $requestVariables = $cacheEntry->getRequestVariables();
                    if(isset($requestVariables['L'])){
                        $requestVariables['L'] = $key;
                        $cacheEntry->setRequestVariables($requestVariables);
                    } 
                }
             }
         }

        parent::setRequestVariables($cacheEntry);

    }
}

在您的ts设置中,它不应该读“config”而不是“configname”吗?临时提示:您没有正确分析您的realurl,顺便说一句;)要详细了解这一点,您可能需要与我联系。编辑配置后清除完整的real_url缓存非常重要,因为翻译后的站点标题可以相同