---
title: "mehrsprachigkeit mit tt_news_languageMenu.php"
url: "https://www.typo3.net/d/35464-mehrsprachigkeit-mit-tt-news-languagemenuphp"
source: "typo3.net"
tags: ["TYPO3","Mehrsprachigkeit","Frage","TYPO3 3","tt_news"]
created: "2005-12-29"
last_reply: "2006-09-29"
replies: 3
solved: false
page: 1
pages: 1
lang: "de"
---

# mehrsprachigkeit mit tt_news_languageMenu.php

TYPO3 › Mehrsprachigkeit · 3 Antworten · gestartet 2005-12-29

## Eröffnungsbeitrag

**molfi** · 2005-12-29 · [Beitrag #1](https://www.typo3.net/d/35464-mehrsprachigkeit-mit-tt-news-languagemenuphp/1)

hallo leute.

ich nutze seit einigen wochen ganz rege dieses forum und habe sehr viele lösungsansätze zu problemen finden können. hierfür schonmal dank an alle.

jetzt sitze ich allerdings seit ein paar tagen an einem problem und komme ncith weiter.
ich habe das mehrsprachigkeits-skript von jweiland.net erfolgreich "installiert". nach einiger zeit ist mir aufgefallen, das dieses die tt_news-parameter in der url nicht weitergibt.

also habe ich es kurzerhand gegen das von tt_news mitgelieferte skript ausgetauscht.
(zu finden in EXT:tt_news/res/tt_news_languageMenu.php)

allerdings erzeugt dieses keine ausgabe.
die marker in meinem html-template werden zwar ersetzt, jedoch mit keinem inhalt.

ich weiß hier ehrlich gesagt nicht weiter. die forumssuche und google habe ich schon tagelang gequält. da wollt ich fragen, ob ihr eine lösung wisst?

mein code sieht wie folgt aus ...

ts setup

```typoscript
#mehrsprachigkeit
#german uid 0
config.linkVars = L
config.sys_language_uid = 0
config.locale_all = german
config.language = de

# english uid 4
[globalVar = GP:L = 4]
config.sys_language_uid = 4
config.language = en
config.locale_all = english
[global]
#russich uid 5
[globalVar = GP:L = 5]
config.sys_language_uid = 5
config.language = ru
config.locale_all = russian
[global]

#skript languages für mehrsprachigkeit
temp.30 = PHP_SCRIPT
temp.30.file = fileadmin/scripts/molfi_languageMenu.php
```

das php-skript so:

```php
<?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!
 */
/**
 * Creates a language-selector menu with three flags, an english, a danish and a german
 * flag for each language supported on the site.
 *
 *
 * $Id: tt_news_languageMenu.php,v 1.14 2005/05/15 19:18:18 rupertgermann Exp $
 *
 * @author Rupert Germann <rupi@gmx.li>
 */

/**
 * language menu that keeps the links vars from tt_news
 *
 * @param	[type]		$content: ...
 * @return	void
 * @access public
 */
function user_languageMenu($content) {
	// image files for deafultlanguage
	$defaultflag = array(
		'on' => '<img src="fileadmin/images/flags/flag_de.gif" alt="" />',
		'off' => '<img src="fileadmin/images/flags/flag_de_d.gif" alt="" />',
	) ;


	// image files for additional languages. the numbers are the uids of the system languages
	$flagimages = array(
		'4' => array(
			'on' => '<img src="fileadmin/images/flags/flag_en.gif" alt="" />',
			'off' => '<img src="fileadmin/images/flags/flag_en_d.gif" alt="" />'
			),
		'5' => array(
			'on' => '<img src="fileadmin/images/flags/flag_ru.gif" alt="" />',
			'off' => '<img src="fileadmin/images/flags/flag_ru_d.gif" alt="" />'
			)
		);
	// Pointer for the active language
	$pointer = '<img src="t3lib/gfx/content_client.gif" width="7" height="10" alt="" />';




	// 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'];
	}

	$queryString = explode('&', t3lib_div::implodeArrayForUrl('', $GLOBALS['_GET'])) ;
	if ($queryString) {
		while (list(, $val) = each($queryString)) {
			$tmp = explode('=', $val);
			$paramArray[$tmp[0]] = $val;
		}
		$excludeList = 'id,L,tx_ttnews[pointer]';
		while (list($key, $val) = each($paramArray)) {
			if (!$val || ($excludeList && t3lib_div::inList($excludeList, $key))) {
				unset($paramArray[$key]);
			}
		}
		$tmpParams = implode($paramArray, '&');

		$newsAddParams = $tmpParams?'&' . $tmpParams:'';
	}
	// unset the global linkVar "L" for the language menu because it's build new in this script
	$linkVarsBak = $GLOBALS['TSFE']->linkVars;
	$tmplinkVars = t3lib_div::trimExplode('&', $GLOBALS['TSFE']->linkVars) ;
	if ($tmplinkVars) {
		while (list($kl, $vl) = each($tmplinkVars)) {
			if (!$vl || preg_match('/L=[0-9]/', $vl)) {
				unset($tmplinkVars[$kl]);
			}
		}
		$GLOBALS['TSFE']->linkVars = implode('&', $tmplinkVars) ;
	}

	$tmpLang = $GLOBALS['TSFE']->sys_language_uid;

	$flags = array();
	// flag for the default language
	if ($GLOBALS['TSFE']->page['l18n_cfg']==1){ // = "Hide default Translation" is activated
		$flags[0] = $defaultflag['off'];
	} else {
		$flags[0] = ($tmpLang == 0?$pointer:'') . $GLOBALS['TSFE']->cObj->typolink($defaultflag['on'], array('parameter' => $GLOBALS['TSFE']->id . ' _top', 'additionalParams' => (!preg_match('/&L=[0-9]/', $newsAddParams)?$newsAddParams . '&L=0':$newsAddParams)));
	}

	// flags for the additional language
	if (is_array($flagimages)) {
		foreach ($flagimages as $fk => $fv) {
			if ($langArr[$fk]) {
				$flags[$fk] = ($tmpLang == $fk?$pointer:'') . $GLOBALS['TSFE']->cObj->typolink($fv['on'], array('parameter' => $GLOBALS['TSFE']->id . ' _top', 'additionalParams' => (!preg_match('/&L=[0-9]/', $newsAddParams)?$newsAddParams . '&L=' . $fk:$newsAddParams)));
			} else {
				$flags[$fk] = $fv['off'];
			}
		}
	}
	$content = '<div class="langmenu"><p>'
	 . implode('', $flags) . '</p></div>';
	// restore link vars
	$GLOBALS['TSFE']->linkVars = $linkVarsBak;
	return $content;
}

?>
```

wenn ich z.b.
<http://localhost/typo3_381/index.php?id=46&tx_ttnews%5Btt_news%5D=7&tx_ttnews%5BbackPid%5D=1&cHash=71e2216143&L=5>
direkt in die adresszeile eingebe, erscheint die richtige seite.

nur funktioniert das skript nicht.
kennt jemand das problem?
für lösungsansätze wäre ich dankbar.

gruß
molfi

ps: im einsatz habe ich
-typo3 3.81
-tt_news 2.24

## Antworten

### [#2](https://www.typo3.net/d/35464-mehrsprachigkeit-mit-tt-news-languagemenuphp/2) · molfi · 2005-12-29

es lag an der einbindung des scripts.
und wenn man lesen könnte, hätte man dies hier sicherlich finden und umsetzen können:

[/d/18231-schon-gesehen-news-202-ist-raus](https://www.typo3.net/d/18231-schon-gesehen-news-202-ist-raus)

... vielleicht war es auch einfach schon zu spät ... was eine mütze voll schlaf doch bewirken kann ;-)

gruß
molfi

### [#3](https://www.typo3.net/d/35464-mehrsprachigkeit-mit-tt-news-languagemenuphp/3) · molfi · 2005-12-29

und wie das immer so ist: standard-code reicht meist nicht aus.
hab das script ein wenig angepasst und wollte euch den code nicht vorenthalten.

das abgewandelte script benutzt statt dem vorangestellten pointer zwei variablen $before und $after, so dass die flagge der aktiven sprache zb direkt mit <span> ... </span> umgeben werden kann. oder was auch immer ...
zusätzlich habe ich die verlinkung der flagge der aktiven sprache herausgenommen (weil die ja schon aktiv ist und warum sollte man sie anklicken wollen?)

... höchstens wenn nicht der komplette content übersetzt wurde
... naja egal, philosophieren kann ich später noch, hier mal der code

```php
<?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!
 */
/**
 * Creates a language-selector menu with three flags, an english, a danish and a german
 * flag for each language supported on the site.
 *
 *
 * $Id: tt_news_languageMenu.php,v 1.14 2005/05/15 19:18:18 rupertgermann Exp $
 *
 * @author Rupert Germann <rupi@gmx.li>
 */

/**
 * language menu that keeps the links vars from tt_news
 *
 * @param	[type]		$content: ...
 * @return	void
 * @access public
 */
 
function user_languageMenu($content) {
$flagpath = 'fileadmin/images/flags/';

	// image files for deafultlanguage
	$defaultflag = array(
		'on' => '<img src="'.$flagpath.'flag_de.gif" alt="DE" title="DE" />',
		'off' => '<img src="'.$flagpath.'flags/flag_de_d.gif" alt="DE" title="DE" />',
	) ;


	// image files for additional languages. the numbers are the uids of the system languages
	$flagimages = array(
		'4' => array(
			'on' => '<img src="'.$flagpath.'flag_en.gif" alt="EN" title="EN" />',
			'off' => '<img src="'.$flagpath.'flag_en_d.gif" alt="" title="" />'
			),
		'5' => array(
			'on' => '<img src="'.$flagpath.'flag_ru.gif" alt="RU" title="RU" />',
			'off' => '<img src="'.$flagpath.'flag_ru_d.gif" alt="RU" title="RU" />'
			)
		);
	
  
	// 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'];
	}

	$queryString = explode('&', t3lib_div::implodeArrayForUrl('', $GLOBALS['_GET'])) ;
	if ($queryString) {
		while (list(, $val) = each($queryString)) {
			$tmp = explode('=', $val);
			$paramArray[$tmp[0]] = $val;
		}
		$excludeList = 'id,L,tx_ttnews[pointer]';
		while (list($key, $val) = each($paramArray)) {
			if (!$val || ($excludeList && t3lib_div::inList($excludeList, $key))) {
				unset($paramArray[$key]);
			}
		}
		$tmpParams = implode($paramArray, '&');

		$newsAddParams = $tmpParams?'&' . $tmpParams:'';
	}
	// unset the global linkVar "L" for the language menu because it's build new in this script
	$linkVarsBak = $GLOBALS['TSFE']->linkVars;
	$tmplinkVars = t3lib_div::trimExplode('&', $GLOBALS['TSFE']->linkVars) ;
	if ($tmplinkVars) {
		while (list($kl, $vl) = each($tmplinkVars)) {
			if (!$vl || preg_match('/L=[0-9]/', $vl)) {
				unset($tmplinkVars[$kl]);
			}
		}
		$GLOBALS['TSFE']->linkVars = implode('&', $tmplinkVars) ;
	}



// Variables which can be filled how ever you want. They are active if the    TSFE->sys_language_uid equals the language uid (notice that the uid has to fit to your own database)). Eg if the variables filled with <div> and </div> it is possible to layout the active language image.
$before = '';
$after = '';


// Pointer for the active language
// You can set $before with the string from $pointer. So it has the same
// function like the original
//	$pointer = '<img src="t3lib/gfx/content_client.gif" title="" alt="" />';

  
  
	$tmpLang = $GLOBALS['TSFE']->sys_language_uid;  
  
  

	$flags = array();
	// flag for the default language
	if ($GLOBALS['TSFE']->page['l18n_cfg']==1){ // = "Hide default Translation" is activated
		$flags[0] = $defaultflag['off'];
	} else {
		$flags[0] = ($tmpLang == 0?''.$before.''.$defaultflag['on'].''.$after : $GLOBALS['TSFE']->cObj->typolink($defaultflag['on'], array('parameter' => $GLOBALS['TSFE']->id . '', 'additionalParams' => (!preg_match('/&L=[0-9]/', $newsAddParams)?$newsAddParams . '&L=0':$newsAddParams)))) ;
	}

  
  // flags for the additional language
	if (is_array($flagimages)) {
		foreach ($flagimages as $fk => $fv) {
			if ($langArr[$fk]) {
				$flags[$fk] = ($tmpLang == $fk?''.$before.''.$fv['on'].''.$after : $GLOBALS['TSFE']->cObj->typolink($fv['on'], array('parameter' => $GLOBALS['TSFE']->id . '', 'additionalParams' => (!preg_match('/&L=[0-9]/', $newsAddParams)?$newsAddParams . '&L=' . $fk:$newsAddParams))));
			} else {
				$flags[$fk] = $fv['off'];
			}
		}
	}
  
  
//	$content = '<div class="langmenu"><p>'. implode('', $flags) . '</p></div>';
	$content = implode('', $flags);
  // restore link vars
	$GLOBALS['TSFE']->linkVars = $linkVarsBak;
	return $content;
}

?>
```

und für diejenigen, die evtl. das skript von jweiland.net benutzen:

```php
<?php
/***************************************************************
*  Copyright notice
*  
*  (c) 1999-2002 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!
***************************************************************/
/**
 * example_languageMenu.php
 *
 * THIS IS AN EXAMPLE designed to work with the official Typo3 testsite, section "Another site in the ..."
 *
 * @author	Kasper Skårhøj <kasper@typo3.com>
 */


 
 // First, select all pages_language_overlay records on the current page. Each represents a possibility for a language.
$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"];
}


//Path to the directory where the flag images are stored
$flagpath = 'fileadmin/images/flags/';


// Variables which can be filled how ever you want. They are active if the TSFE->sys_language_uid equals the language uid (notice that the uid has to fit to your own database)). Eg if the variables filled with <div> and </div> it is possible to layout the active language image.
$before = '';
$after = '';


// Set each icon. If the language is the current, $before is printed to the left and $after ist printed to the right. If the language is NOT found (represented by a pages_language_overlay record on this page), the icon is dimmed and not linked. Also the active language is not linked, too.
$flags = array();

$flags[] = ($GLOBALS["TSFE"]->sys_language_uid==0?''.$before.'<img src="'.$flagpath.'flag_de.gif" alt="DE" title="DE" />'.$after.' ':'<a href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=0"><img src="'.$flagpath.'flag_de.gif" alt="DE" title="DE" /></a> ');



$flags[] = ($GLOBALS["TSFE"]->sys_language_uid==4?''.$before.'<img src="'.$flagpath.'flag_en.gif" alt="EN" title="EN" />'.$after.' ':''.($langArr[4]?'<a href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=4"><img src="'.$flagpath.'flag_en.gif" alt="EN" title="EN" /></a> ':'<img src="'.$flagpath.'flag_en_d.gif" alt="EN" title="EN" /> ').'');

$flags[] = ($GLOBALS["TSFE"]->sys_language_uid==5?''.$before.'<img src="'.$flagpath.'flag_ru.gif" alt="RU" title="RU" />'.$after.' ':''.($langArr[5]?'<a href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=5"><img src="'.$flagpath.'flag_ru.gif" alt="RU" title="RU" /></a> ':'<img src="'.$flagpath.'flag_ru_d.gif" alt="RU" title="RU" /> ').'');




// 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);
?>
```

wie gesagt: wollte euch den code nicht vorenthalten.
für alle, die es gebrauchen können.
keine garantie auf funktion.

gruß
molfi

### [#4](https://www.typo3.net/d/35464-mehrsprachigkeit-mit-tt-news-languagemenuphp/4) · Tank_jr · 2006-09-29

ja, das ist es was ich lange gesucht habe.

allerdings habe ich noch eine frage als anfänger dazu.

diesen link habe ich gelesen:
[/d/18231-schon-gesehen-news-202-ist-raus](https://www.typo3.net/d/18231-schon-gesehen-news-202-ist-raus)
konnte es aber nicht anwenden.

ich habe in meiner setup das zu stehen:

```typoscript
page.10{
   template = FILE
   template.file = fileadmin/vorlagen/vorlage.html
   workOnSubpart = DOKUMENT
   
   ### SPRACHUMSCHALTUNG ###
   includeLibs.something = fileadmin/scripts/tt_news_languageMenu.php
   
   marks.SPRACHEN = USER
   marks.SPRACHEN {
      userFunc = user_languageMenu
   } 
   ...
```

leider zeigt er mir die flaggen nicht an.

wo liegt mein fehler?

danke

---

Quelle: „mehrsprachigkeit mit tt_news_languageMenu.php“, typo3.net, https://www.typo3.net/d/35464-mehrsprachigkeit-mit-tt-news-languagemenuphp
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
