[TYPO3-english] Language key in url
Richard Jäger
richard_j at arcor.de
Wed Jun 3 13:50:02 CEST 2009
Hey,
right now users can switch language by clicking on german or english on
the frontpage, it just adds an L=X, like index.php?id=383&L=0
But im using realurl, so its a bit "ugly". If ur surfing the english
site the url looks like www.xxx.de/en/bookshop.html and in german
www.xxx.de/de/bookshop.html
So my question is now, is it possible to change the "de" or "en" if
someone clicks on a language?
Im using a .inc file for that:
<?php
if (!is_object($this)) die ('Error: No parent object present.');
// First, select all pages_language_overlay records on the current page.
Each represents a possibility for a language.
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*',
'pages_language_overlay',
'pid='.intval($GLOBALS['TSFE']->id).$GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'),
'sys_language_uid');
$langArr = array();
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$langArr[$row['sys_language_uid']] = $row['title'];
}
// Little red arrow, which is inserted to the left of the flag-icon if
the TSFE->sys_language_uid equals the language uid (notice that
0=english, 1=danish and 2=german is SPECIFIC to this database, because
these numbers refer to uid's of the table sys_language)
//$pointer = '<img
src="'.t3lib_extMgm::siteRelPath('cms').'tslib/media/icons_misc/content_client.gif"
width="7" height="10" alt="" />';
$pointer = '';
// Set each icon. If the language is the current, red arrow is printed
to the left. If the language is NOT found (represented by a
pages_language_overlay record on this page), the icon is dimmed.
$flags = array();
$flags[] = ($GLOBALS['TSFE']->sys_language_uid==0?$pointer:'').'<ul
class="lang_menu"><li><img
src="fileadmin/templates/images/right_arrow.gif" alt=""/> <a
href="'.htmlspecialchars('index.php?id='.$GLOBALS['TSFE']->id.'&L=1').'"
target="_top">English</a></li>';
$flags[] = ($GLOBALS['TSFE']->sys_language_uid==1?$pointer:'').'<li><img
src="fileadmin/templates/images/right_arrow.gif" alt=""/> <a
href="'.htmlspecialchars('index.php?id='.$GLOBALS['TSFE']->id.'&L=0').'"
target="_top">Deutsch</a></li></ul>';
// Make the little menu. Notice, the menu does ONLY transfer the page-id
and the "L" variable (which is also SPECIFIC for this website because
"L" has been used in the extension template used to control the language
setup)
$content = ''.implode('',$flags).'';
?>
Thanks soooo much in advance, i hope u understand my question :)
More information about the TYPO3-english
mailing list