ok, hier also die zusammenfassung für alle anderen zum mitschreiben... 😉
zwei (beispiel)versionen einer angepaßten example_languageMenu.php. sie dienen zum "seitengenauen" umschalten bei einer one-tree-fits-all umsetzung von mehreren sprachversionen einer website bei verwendung der extension realurl:
da wäre zum einen die klassische version mit den flaggen, die ja standardmäßig von typo3 mitgeliefert wird. hier mit english als id=0 und deutsch als id=1
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
$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'];
}
$pointer = '<img src="t3lib/gfx/content_client.gif" width="7" height="10" align="middle" alt="" />';
$flags[] = ($GLOBALS['TSFE']->sys_language_uid==0?$pointer:'').'<a href="'.htmlspecialchars('index.php?id='.$GLOBALS['TSFE']->id.'&L=0&ch_lang=1').'" target="_top"><img src="media/uploads/flag_uk.gif" width="21" height="13" hspace="5" border="0" alt="" /></a>';
$flags[] = ($GLOBALS['TSFE']->sys_language_uid==1?$pointer:'').'<a href="'.htmlspecialchars('index.php?id='.$GLOBALS['TSFE']->id.'&L=1&ch_lang=1').'" target="_top"><img src="media/uploads/flag_de'.($langArr[1]?'':'_d').'.gif" width="21" height="13" hspace="5" border="0" alt="" /></a>';
$content = '<table border="0" cellpadding="0" cellspacing="0"><tr><td><img src="clear.gif" width="30" height="1" alt="" /></td><td>'.implode('',$flags).'</td></tr></table>';
?>
zum anderen eine version, die textlinks liefert ("deutsch", bzw. "english"). es wird dabei immer nur ein link angezeigt (logischerweise nur der, der zur jeweils anderen sprache führt... 😉).
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2003 Kasper Skårhøj (kasper@typo3.com)
* All rights reserved
*
* This script is part of the Typo3 project. The Typo3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
$query = "SELECT * FROM pages_language_overlay WHERE pid=".$GLOBALS["TSFE"]->id.$GLOBALS["TSFE"]->sys_page->enableFields("pages_language_overlay")." GROUP BY sys_language_uid";
$res = mysql(TYPO3_db,$query);
$langArr=array();
while($row=mysql_fetch_assoc($res)) {
$langArr[$row["sys_language_uid"]]=$row["title"];
}
$english = '[<a href="'.htmlspecialchars('index.php?id='.$GLOBALS['TSFE']->id.'&L=0&ch_lang=1').'">english</a>]';
$deutsch = '[<a href="'.htmlspecialchars('index.php?id='.$GLOBALS['TSFE']->id.'&L=1&ch_lang=1').'">deutsch</a>]';
$flags = array();
$flags[] = ($GLOBALS["TSFE"]->sys_language_uid==0?$deutsch:"");
$flags[] = ($GLOBALS["TSFE"]->sys_language_uid==1?$english:"");
$content = '<div style="position: absolute; text-align: right; right:0px; width:200px; height:15px; background-color:#ffffff;" class="language">'.implode("",$flags).'</div>';
?>
ich hatte hier übrigens einfach keinen bock $flags umzubenennen. es gibt natürlich keine flaggen...
alles funktioniert aber nur dann so schön, wenn man folgende änderung in typo3conf/ext/realurl/class.ux_tslib_fe.php (ungefähr zeile 616) macht
[....]
$result = array();
//HH-Hack
if(preg_match("/ch_lang=1/",$uri))
$uri = preg_replace("/?id=(d+)&L=(d+)&ch_lang=1/","",$uri);
//HH-Hack ende
$parsed = parse_url($uri); // Let PHP do the first run
[....]
nochmals großen dank an AFisch! 🙂