[TYPO3-english] Issue after removing 'fr' part [SOLVED]

Xavier Perseguers typo3 at perseguers.ch
Sun Feb 15 12:36:48 CET 2009


I'm posting my solution to help others that may find it useful or get 
ideas out of it.

> Using RealURL, my links are generated this way when I'm on page1:
> 
> http://www.domain.tld/
> http://www.domain.tld/page1.1
> http://www.domain.tld/fr/share/subpages
> 
> (note the "fr" in the last link)
> 
> But when I'm on subpages, links are all prepended with "fr":
> 
> http://www.domain.tld/fr
> http://www.domain.tld/fr/page1.1
> http://www.domain.tld/fr/share/subpages
> 
> Now I remember why I wanted all my pages to be prefixed by the language, 
> even if default language was used.
> 
> ... Meaning I have to find the solution XCLASSing RealURL to dynamically 
> specify the default language to be used.

I found what seems to be the only viable solution and it does not need 
XCLASSing anymore either.

All my websites are dynamically generated, as such, I already generated 
a file to be included at the beginning of my realurl_conf.php file in 
order to specify the rootpage_id of my websites. I now changed it a bit 
to include the default language of the website:

// file realurl_project.php
$configHosts = array(
         'somedomain.domain.tld' => array(
                 'uid' => 4,
                 'defaultLanguage' => 'fr',
         ),
         'other.domain.tld' => array(
                 'uid' => 12,
                 'defaultLanguage' => 'de',
         ),
);

And in my realurl_conf.php (only relevant parts are shown):

?php
require_once('realurl_project.php');

$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array(
	// snip
	'preVars' => array(
		array(
			// snip
		),
		array(
			'GETvar'   => 'L',
			'valueMap' => array(
				'de' => '1',
				'fr' => '2',
				'it' => '3',
				'en' => '4',
			),
			'valueDefault' => '{DYNAMIC}', // will be overriden with code below
		),
	),
	'pagePath' => array(
		'type'                => 'user',
		'userFunc'            => 
'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
		'spaceCharacter'      => '-',
		'languageGetVar'      => 'L',
		'disablePathCache'    => 0,
		'expireDays'          => 7,
		'rootpage_id'         => 1, // will be overriden with code below
		'segTitleFieldList'   => 'tx_realurl_pathsegment,alias,nav_title,title',
	),
	// snip
);

$config = $configHosts[$_SERVER['HTTP_HOST']];

if ($config) {
	$defaultLanguage = $config['defaultLanguage'];
	$rootpage_id = $config['uid'];

		// Update default language
	$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']['preVars'][1]['valueDefault'] 
= $defaultLanguage;

		// Unset mapping for default language to force sys_language_uid = 0 for it
	unset($TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']['preVars'][1]['valueMap'][$defaultLanguage]);

		// Set rootpage id
	$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']['pagePath']['rootpage_id'] 
= $rootpage_id;
}


-- 
Xavier Perseguers
http://xavier.perseguers.ch/en

One contribution a day keeps the fork away


More information about the TYPO3-english mailing list