Zum Inhalt springen

Cannot modify header information language.php

Erstellt am 3. August 2009 · 2 Antworten · letzte Antwort am 3. September 2009

Tags: Frage

carstenK ·

Hallo,
ich habe eine PHPScript für den Sprachwechsel eingebunden, seit dem bekomme ich diese Meldung. Was kann das sein, woran könnte das liege, was kann ich dagegen tun?

Warning: Cannot modify header information - headers already sent by (output started at .../uploads/media/scripts/language.php:1) in .../typo3/sysext/cms/tslib/class.tslib_fe.php on line 2963

LG Carsten

<?php 
/***************************************************************
*  Copyright notice
*  
*  (c) 1999-2002 Kasper Skrhj (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 Skrhj <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"];
}

// 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/gfx/content_client.gif" width="7" height="10" align="middle" alt="" />';
$pointer = '<img src="fileadmin/img/pfeilchen.gif" align="middle" alt="" />';

// 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:"").'<a href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=0" target=_top><img src="media/uploads/flag_de.gif" width="21" height="13" hspace="5" border="0" alt="" /></a>';
//$flags[] = ($GLOBALS["TSFE"]->sys_language_uid==3?$pointer:"").'<a href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=3" target=_top><img src="media/uploads/flag_uk'.($langArr[3]?" :="" _dgif="" width="21" height="13" hspace="5" border="0" alt="" /></a>';
#$flags[] = ($GLOBALS["TSFE"]->sys_language_uid==0?"":"").'<a class="navi" href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=0" target="_top" title="Deutsch"><img src="fileadmin/template/integ/images/flags/de.gif" border="0" alt="Deutsch" longdesc="Deutsch" /></a>';
if ($GLOBALS["TSFE"]->sys_language_uid==0) {
$flags[] = ($GLOBALS["TSFE"]->sys_language_uid==0?"":"").'<div id="menueLang" class="langMenue"><ul><li><a href="index.php?id='.$GLOBALS[" tsfe-="">id.'" target="_top" rel="langMenue_01">DE</a></li></ul></div><div id="langMenue" class="ecsMenue_01"><div id="langMenue_01" class="langOpenMenue"><ul><li><a class="navi" href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=1" target="_top">TR</a></li><li><a class="navi" href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=2" target="_top">EN</a></li></ul></div></div>';
} elseif ($GLOBALS["TSFE"]->sys_language_uid==1) {	
$flags[] = ($GLOBALS["TSFE"]->sys_language_uid==1?"":"").'<div id="menueLang" class="langMenue"><ul><li><a href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=1" target="_top" rel="langMenue_01">TR</a></li></ul></div><div id="langMenue" class="ecsMenue_01"><div id="langMenue_01" class="langOpenMenue"><ul><li><a class="navi" href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=2" target="_top">EN</a></li><li><a class="navi" href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=0" target="_top">DE</a></li></ul></div></div>';
} elseif ($GLOBALS["TSFE"]->sys_language_uid==2) {
$flags[] = ($GLOBALS["TSFE"]->sys_language_uid==2?"":"").'<div id="menueLang" class="langMenue"><ul><li><a href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=2" target="_top" rel="langMenue_01">EN</a></li></ul></div><div id="langMenue" class="ecsMenue_01"><div id="langMenue_01" class="langOpenMenue"><ul><li><a class="navi" href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=0" target="_top">DE</a></li><li><a class="navi" href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=1" target="_top">TR</a></li></ul></div></div>';
}
#$flags[] = ($GLOBALS["TSFE"]->sys_language_uid==2?"":"").'<a class="navi" href="index.php?id='.$GLOBALS[" tsfe-="">id.'&L=2" target="_top" title="Francais"><img src="fileadmin/template/integ/images/flags/fr.gif" border="0" alt="Francais" longdesc="Francais" /></a> ';
// 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 = '<table border="0" cellpadding="0" cellspacing="0"><tr><td><img src="clear.gif" width="10" height="1" alt="" /></td><td>'.implode(" ",$flags).'</td></</tr></table>';
$content = ''.implode(" ",$flags).'';
?>
vixe ·

Hallo,

das liegt daran, dass Dein Code eine Ausgabe erzeugt und diese Ausgabe kommt entweder vor einer von TYPO3 über "header()" erzeugten Ausgabe oder bevor eine Session generiert wird.

Aus welchem Grund muss man überhaupt ein Language - Menu über PHP erzeugen?
Soltle eigentlich alles über HMENU.special = language zu lösen sein.

Gruß

carstenK ·

Hi,
weil ich das mit HMENU.special = language nicht so gewrap bekomme wie ich es benötige. Habe das jetzt x mal mit HMENU.special = language probiert oder meine kenntnisse reichen nicht aus, bin für jeden Tip dankbar.

Das Problem ist das alle 3 sprachen den zustand NO bekommen.

Zuordnung der Sprachen
default = de
gr = &L=1
en = &L=2

wrap für die aktive Sprache

<div id="menueLang" class="langMenue">
<ul>
<li class="selectedLangDE"><a href="index.php?id='.$GLOBALS["TSFE"]->id.'" target="_top" rel="langMenue_01">Deutsch</a></li>
</ul>
</div>

wrap für die inaktiven Sprachen

<div id="langMenue" class="ecsMenue_01">
<div id="langMenue_01" class="langOpenMenue">
<ul>
<li class="langGR"><a href="index.php?id='.$GLOBALS["TSFE"]->id.'&L=1" target="_top">&#949;&#955;&#955;&#951;&#957;&#953;&#954;&#940;</a></li>
<li class="langEN"><a href="index.php?id='.$GLOBALS["TSFE"]->id.'&L=2" target="_top">English</a></li>
</ul>
</div>
</div>

Grüße