Zum Inhalt springen

tt_calender

Erstellt am 18. August 2003 · 11 Antworten · letzte Antwort am 19. Februar 2005

Tags: Frage

Gottfried19 ·

gut habs geschafft. habs in der datei calender.inc bei zeile 106 editiert:

$tConf["marks."]["DATE."]["value"]=date("d.m.Y",$row[date]);
Oli ·

Danke Gottfried19. Das wollte ich auch wissen!
Kann mir außerdem jemand sagen, weshalb die Uhrzeit nicht angezeigt wird? muß ich dafür etwas ins Template schreiben?

tino ·
Oli schrieb

Kann mir außerdem jemand sagen, weshalb die Uhrzeit nicht angezeigt wird? muß ich dafür etwas ins Template schreiben?

Ja. Ich. Es wird nicht die Zeit übernommen, die im Feld "Zeit" steht. Man muß im Feld "Bemerkungen" als erstes die Zeit eintragen (z.B. 19:00 texttext...).

Im Template muß mMn nichts geändert werden.

Tino

emueller ·

Hallo, kann mir jemand sagen für was die Felder:
Woche
Karegorie
Datumstext
Link zur Seite

da sind.

Das währe echt super. #giggle#
eric

hardcoder ·

@emueller

DIe sind dazu da um die tt_calender-Tabelle der Datenbank zu befüllen :-)

Diese werden aber im Standard-Template nicht verwendet. Damit zumindest der Inhalt "Datumstext" mit dem ziel "Link zur Seite" klappt habe ich die Dateien

calendar.inc und calendar_template.tmpl so modifiziert: (die geänderten stellen sind mit * markiert)

//calendar.inc


<?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!
***************************************************************/
/**
 * calendar.inc
 *
 * Creates a calendar
 * 
 * NOTICE: This script does not represent the most effective way to insert custom functionality in Typo3 page. Please use the USER object with a class instead.
 *
 * @author	Kasper Skårhøj <kasper@typo3.com>
 */

 
$content="";

// *************************************
// *** getting configuration values:
// *************************************

		// getting configuration values:
	$config["pid_list"] = trim($this->stdWrap($conf["pid_list"],$conf["pid_list."]));
	$config["pid_list"] = $config[pid_list] ? $config["pid_list"] : $GLOBALS["TSFE"]->id;

	$config["recursive"] = $this->stdWrap($conf["recursive"],$conf["recursive."]);

	$config["font"] = $this->stdWrap($conf["fontFace"],$conf["fontFace."]);
	$config["font"] = $config["font"] ? $config["font"] : "verdana";

		// If the current record should be displayed.
	$config["displayCurrentRecord"] = $conf["displayCurrentRecord"];

	
	$templateCode = $this->fileResource($conf["templateFile"]);

		// Fetching catagories:
	$categories = Array();
 	$query = "select * from tt_calender_cat where 1=1".$this->enableFields("tt_calender_cat");
	$res = mysql(TYPO3_db,$query);
	echo mysql_error();
	while($row = mysql_fetch_assoc($res))	{
		$categories[$row[uid]] = $row[title];
	}	

	
		// making query:
	$selectConf = Array();
	if ($config[recursive])	{		// get pid-list if recursivity is enabled
		$pid_list_arr = explode(",",$config[pid_list]);
		$orig_pids = $config[pid_list];
		$config[pid_list]="";
		while(list(,$val)=each($pid_list_arr))	{
			$config[pid_list].=$this->getTreeList($val,intval($config["recursive"]));
		}
		$config[pid_list].=$orig_pids;
	}
	$selectConf["pidInList"] = $config[pid_list];
	$selectConf["orderBy"] = "date,time";
	$selectConf["where"] = "type=0";
	if (intval($conf["maxAge"]))	{
		$selectConf["where"].= " AND date>".(time()-(3600*24*intval($conf["maxAge"])));
	}

		// performing query:
 	$query = $this->getQuery("tt_calender",$selectConf);
	$res = mysql(TYPO3_db,$query);
	echo mysql_error();
	
		// traversing the data.
	$tableRows = "";
	$day_base = mktime (0,0,0,date("m"),date("d"),date("Y"));

		// config af template:
	$tConf["template"] ="HTML";
	$tConf["template."]["value"] = $templateCode;
	
	while($config["displayCurrentRecord"] || $row = mysql_fetch_assoc($res))	{
		if ($config["displayCurrentRecord"])	{$row = $this->data;}
			// Insering date header:			
		$tConf["workOnSubpart"] = "DATE_HEADER";
		$tConf["marks."] = Array ();
		$tConf["marks."]["DATE"]="HTML";
		$tConf["marks."]["DATE."]["value"]=date("d.m.Y",$row[date]);
		$tConf["marks."]["HEADER"]="HTML";
		$tConf["marks."]["HEADER."]["value"]=$row[title];
		$tConf["marks."]["FONT"]="HTML";
		$tConf["marks."]["FONT."]["value"]=$config[font];
		$tableRows.=$this->TEMPLATE($tConf);

		
		$parts = explode(chr(10)."---".chr(10), str_replace(chr(13),"",$row[note]));
		while(list(,$pcon)=each($parts))	{
			$pcon=trim($pcon);
			$pcon_arr=split(chr(10),$pcon,2);
			$theTime = "";

			$hP=explode(" ",$pcon_arr[0],2);
			if (ereg("[^0-9,.:;-]",$hP[0]))	{
				$title = trim($pcon_arr[0]);
			} else {
				$title = trim($hP[1]);
				$theTime = trim($hP[0]);
			}
			if ($conf["parseFunc."]) {
				$title = $this->parseFunc($title,$conf["parseFunc."]);
				$pcon_arr[1] = $this->parseFunc($pcon_arr[1],$conf["parseFunc."]);
			}
			$theContent = "<b>".$title."</b><BR>".nl2br($pcon_arr[1]);
			*$theLink="";
			if($row[link])$theLink = "<a href="index.php?id=".$row[link]."">".$row[datetext]."</a>";*

				// Insering date header:			
			$tConf["workOnSubpart"] = "DATE_CONTENT";
			$tConf["marks."] = Array ();
			$tConf["marks."]["TIME"]="HTML";
			$tConf["marks."]["TIME."]["value"]= $theTime;
			$tConf["marks."]["CONTENT"]="HTML";
			$tConf["marks."]["CONTENT."]["value"]=$theContent;
			*$tConf["marks."]["LINK"]="HTML";
			$tConf["marks."]["LINK."]["value"]=$theLink;*
			$tConf["marks."]["FONT"]="HTML";
			$tConf["marks."]["FONT."]["value"]=$config[font];
			$tableRows.=$this->TEMPLATE($tConf);
	
		}

		$this->lastChanged($row[tstamp]);


		if ($config["displayCurrentRecord"])	{break;}	// Must exit forcibly or we'll have an eternal loop.
	}

	$tConf["workOnSubpart"] = "TEMPLATE_CALENDAR";
	$tConf["marks."] = Array ();
	$tConf["subparts."] = Array ();
	$tConf["subparts."]["TABLE_CONTENT"]="HTML";
	$tConf["subparts."]["TABLE_CONTENT."]["value"]= $tableRows;


	$content = $this->TEMPLATE($tConf);


$RESTORE_OLD_DATA = 1;		// secures a restore of the original ->data-array

?>

***********************************

//calendar_template.tmpl

......

<!-- ###TEMPLATE_CALENDAR### -->
	<table border=0 cellpadding=2 cellspacing=2>
	<!-- ###TABLE_CONTENT### -->
		<!-- ###DATE_HEADER### -->
		<tr>
			<td NOWRAP><font face="###FONT###" size=2 color="black"> ###DATE### </font></td>
			<td><font face="###FONT###" size=2 color="black"><b> ###HEADER### </b></font></td>
		</tr>
		<!-- ###DATE_HEADER### -->
		<!-- ###DATE_CONTENT### -->
		<tr>
			<td align="right" valign="top"><font face="###FONT###" size=1 color="black">###TIME###</font></td>
			*<td valign="top"><font face="###FONT###" size=2 color="black">###CONTENT### ###LINK###</font></td>*
		</tr>
		<!-- ###DATE_CONTENT### -->
	<!-- ###TABLE_CONTENT### -->
	</table>
<!-- ###TEMPLATE_CALENDAR### -->

......
wikki ·

ich habe ebenfalls einige zeilen geändert. ich wollte, dass optional der datumstext angezeigt wird, wenn einer existiert. ansonsten soll ganz normal das datum angezeigt werden.

in der calendar.inc

	while($config["displayCurrentRecord"] || $row = mysql_fetch_assoc($res))	{
		if ($config["displayCurrentRecord"])	{$row = $this->data;}
			// Insering date header:
		$tConf["workOnSubpart"] = "DATE_HEADER";
		$tConf["marks."] = Array ();
		$tConf["marks."]["DATE"]="HTML";
		*if($row[datetext]){
			$tConf["marks."]["DATE."]["value"]=$row[datetext];
		}else{
			$tConf["marks."]["DATE."]["value"]=date("d.m.Y",$row[date]);
		}*
		$tConf["marks."]["HEADER"]="HTML";
		$tConf["marks."]["HEADER."]["value"]=$row[title];
		$tConf["marks."]["FONT"]="HTML";
		$tConf["marks."]["FONT."]["value"]=$config[font];
		$tableRows.=$this->TEMPLATE($tConf);

der rest bleibt alles gleich.

Aber eine andere Frage. Weiss jemand, wie man den RTE für tt_calendar aktiviert? Irgendwie sind da einem die Hände gebunden.

hulla ·

Hallo, da ich keine Ahnung von php habe und den code nur ganz dumpf kopiert habe...

ich bekomme diese fehlermeldung:
Parse error: parse error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /www/typo3/typo3/ext/tt_calender/pi/calendar.inc on line 136

Muss was mit der Zeile

         *$theLink=""; 
         if($row[link])$theLink = "<a href="index.php?id=".$row[link]."">".$row[datetext]."</a>";*

zu tun haben, oder? (die sternchen habe ich nicht kopiert...)

Kann mir jemand helfen?

sirTeddy ·

Hi, habe hier auch eine etwas abgeänderte Version: Der Code geht davon aus das man pro Kalendereintrag ein neues Kalender-Element anlegt und nicht einfach alle Einträge in ein Element einfügt und durch "---" trennt. Des weiteren werden alle Einträge eines Tages zusammengefasst und durch ein optionales HR getrennt. Sieht ganz gut aus 8-)

Hier ist der Code:

$content="";

// *************************************
// *** getting configuration values:
// *************************************

	// getting configuration values:
	$config["pid_list"] = trim($this->stdWrap($conf["pid_list"],$conf["pid_list."]));
	$config["pid_list"] = $config[pid_list] ? $config["pid_list"] : $GLOBALS["TSFE"]->id;
	$config["recursive"] = $this->stdWrap($conf["recursive"],$conf["recursive."]);
	$config["font"] = $this->stdWrap($conf["fontFace"],$conf["fontFace."]);
	$config["font"] = $config["font"] ? $config["font"] : "verdana";

	// If the current record should be displayed.
	$config["displayCurrentRecord"] = $conf["displayCurrentRecord"];
	$templateCode = $this->fileResource($conf["templateFile"]);

	// Fetching catagories:
	$categories = Array();
 	$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_calender_cat', '1=1'.$this->enableFields('tt_calender_cat'));
	while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
		$categories[$row['uid']] = $row['title'];
	}

	// making query:
	$selectConf = Array();
	if ($config[recursive])	{		// get pid-list if recursivity is enabled
		$pid_list_arr = explode(",",$config[pid_list]);
		$orig_pids = $config[pid_list];
		$config[pid_list]="";
		while(list(,$val)=each($pid_list_arr))	{
			$config[pid_list].=$this->getTreeList($val,intval($config["recursive"]));
		}
		$config[pid_list].=$orig_pids;
	}
	$selectConf["pidInList"] = $config[pid_list];
	$selectConf["orderBy"] = "date,time";
	$selectConf["where"] = "type=0";

	// performing query:
 	$res = $this->exec_getQuery("tt_calender",$selectConf);

	// traversing the data.
	$tableRows = "";
	$day_base = mktime (0,0,0,date("m"),date("d"),date("Y"));

	// config af template:
	$tConf["template"] ="HTML";
	$tConf["template."]["value"] = $templateCode;

    $datumAnzeige = array();
	while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
        // Versuche doppelte Einträge zu vermeiden:
        if (!in_array($row[date], $datumAnzeige)) {
            $datumAnzeige[] = $row[date];

    		// Insering date header:
    		$tConf["workOnSubpart"] = "DATE_HEADER";
    		$tConf["marks."] = Array ();
    		$tConf["marks."]["DATE"]="HTML";
    		$tConf["marks."]["DATE."]["value"]=date("d.m.y",$row[date]);
    		$tableRows.=$this->TEMPLATE($tConf);
    
    		// Neue SQL Anfrage: Alle Einträge eines Tages auslesen
            $neueSQLAnfrage = Array();
            $neueSQLAnfrage["pidInList"] = $config[pid_list];
            $neueSQLAnfrage["orderBy"] = "time";
            $neueSQLAnfrage["where"] = "date=".$row[date];

           	// performing query:
            $sqlResNeu = $this->exec_getQuery("tt_calender",$neueSQLAnfrage);
            $sqlAnzahlEintraege = mysql_num_rows($sqlResNeu);
            $lauf = 0;

            while ($row_neu = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($sqlResNeu)) {
                $lauf++;

                // Preparing categoryname:
                if (!$row_neu[category])
                    $tmpCatName = "<I>Alles</I>";
                else
                    $tmpCatName = $categories[$row[category]];

    			// Insering date header:
    			$tConf["workOnSubpart"] = "DATE_CONTENT";
    			$tConf["marks."] = Array ();
    			$tConf["marks."]["TIME"]="HTML";
    			$tConf["marks."]["TIME."]["value"] = date("H:i", $row_neu[time]);
    			$tConf["marks."]["WEEK"]="HTML";
    			$tConf["marks."]["WEEK."]["value"] = $row_neu[week];
    			$tConf["marks."]["TITLE1"]="HTML";
    			$tConf["marks."]["TITLE1."]["value"] = $row_neu[title];
    			$tConf["marks."]["DESCRIPT1"]="HTML";
    			$tConf["marks."]["DESCRIPT1."]["value"] = $row_neu[note];
    			$tConf["marks."]["CATEGORY"]="HTML";
    			$tConf["marks."]["CATEGORY."]["value"] = $tmpCatName;
    			$tConf["marks."]["TITLE2"]="HTML";
    			$tConf["marks."]["TITLE2."]["value"] = $row_neu[datetext];

                if ($sqlAnzahlEintraege > $lauf) {
        			$tConf["marks."]["TRENNLINIE"]="HTML";
        			$tConf["marks."]["TRENNLINIE."]["value"] = "<TR><TD style="border-style:none;">&nbsp;</TD><TD colspan="2" style="border-style:none;"><HR size="1" width="100%"></TD></TR>";
                } else {
        			$tConf["marks."]["TRENNLINIE"]="HTML";
        			$tConf["marks."]["TRENNLINIE."]["value"] = "";
                }

    			// URL anpassen:
    			$tConf["marks."]["URL"]="HTML";
    			if (!empty($row_neu[link]))
                    $tConf["marks."]["URL."]["value"] = "(<A href="index.php?id=".$row_neu[link]."" title="".$row_neu[datetext]."">mehr</A>)";
        		else
                    $tConf["marks."]["URL."]["value"] = "";

                $this->lastChanged($row[tstamp]);
                // Daten in das Template schreiben:
    			$tableRows.=$this->TEMPLATE($tConf);
            }
        }
	}

	$tConf["workOnSubpart"] = "TEMPLATE_CALENDAR";
	$tConf["marks."] = Array ();
	$tConf["subparts."] = Array ();
	$tConf["subparts."]["TABLE_CONTENT"]="HTML";
	$tConf["subparts."]["TABLE_CONTENT."]["value"]= $tableRows;
	$content = $this->TEMPLATE($tConf);

    $RESTORE_OLD_DATA = 1;

Das ganze ist sehr angepasster Code und mit sicherheit nicht für jeden ohne weiteres nutzbar... Aber vielleicht hilft das Konzept irgendwem.

Hier das Template:

<!-- ###TEMPLATE_CALENDAR### -->
	<TABLE border="1" cellpadding="0" cellspacing="1" style="border-style:none;" width="100%">
		<TR>
			<TD width="5%" align="center" bgcolor="#ccddcc"><STRONG>Uhrzeit</STRONG></TD>
			<TD width="75%" bgcolor="#ccddcc"><STRONG>Beschreibung</STRONG></TD>
    		<TD width="20%" align="right" bgcolor="#ccddcc"><STRONG>Kategorie</STRONG></TD>
		</TR>
    	<!-- ###TABLE_CONTENT### -->

    		<!-- ###DATE_HEADER### -->
    		<TR>
    			<TD bgcolor="#eeeeee" colspan="3" style="border-style:none;"><I>###DATE###</I></TD>
    		</TR>
    		<!-- ###DATE_HEADER### -->

    		<!-- ###DATE_CONTENT### -->
    		<TR>
    			<TD align="center" valign="top" style="border-style:none;">###TIME###</TD>
    			<TD valign="top" style="border-style:none;">
                    <DIV>###TITLE1###</DIV>
                    <DIV>###DESCRIPT1### ###URL###</DIV>
                </TD>
                <TD align="right" valign="top" style="border-style:none;">###CATEGORY###</TD>
    		</TR>
    		###TRENNLINIE###
    		<!-- ###DATE_CONTENT### -->

    	<!-- ###TABLE_CONTENT### -->
	</TABLE>
<!-- ###TEMPLATE_CALENDAR### -->


Header              Feld                Format              Bemerkung
------------------------------------------------------------------------------
###DATE###          "Datum"             dd.mm.yy
###TIME###          "Zeit"              hh.mm
###WEEK###          "Woche"             1-52
###TITLE1###        "Titel"             <string>
###DESCRIPT1###     "Bemerkung"         <string>
###CATEGORY####     "Kategorie"         <auswahl::string>
###TITLE2###        "Datumstext"        <string>            Text für TITLE der URL
###URL###           "Link zur Seite"    <auswahl::url>      Link auf andere Seite
###TRENNLINIE###    ---                 <TR> ... </TR>      fügt ein HR Element als neue TR ein

Gruß - Christian

sirTeddy ·

Tja, nobody is perfect und ab und an fallen Dinge auch erst im Nachhinein auf #paralyzed#

Hier ist ein kleiner "Bugfix" für falsche Kategorienamen:

// Preparing categoryname: 
                if (!$row_neu[category]) 
                    $tmpCatName = "<I>Alles</I>"; 
                else 
                    $tmpCatName = $categories[$row[category]];

muss heissen

                // Preparing categoryname:
                if (!$row_neu[category])
                    $tmpCatName = "<I>Alles</I>";
                else
                    $tmpCatName = $categories[$row_neu["category"]];
torst.​ ·

Hallo zusammen!

Ich habe versuche den oben angegebenen Code anzuwenden, um den Datumstext mit dem Link verbunden darzustellen, doch leider gab dies nur Fehlermeldungen. (Mit scheinen dort auch ein paar Fehler versteckt zu sein)

Meine relativ einfache Lösung:
Hier mein wirklich aller erster PHP Code :o

PHP-Datei "calendar.inc"

		// Insering date header:			
		$tConf["workOnSubpart"] = "DATE_HEADER";
		$tConf["marks."] = Array ();
		$tConf["marks."]["DATE"]="HTML";
		$tConf["marks."]["DATE."]["value"]=date("d/m Y",$row[date]);
		$tConf["marks."]["HEADER"]="HTML";
		$tConf["marks."]["HEADER."]["value"]=$row[title];
		$theLink="<a href=index.php?id=".$row[link].">".$row[datetext]."</a>";
		$tConf["marks."]["DATETEXT"]="HTML";
		$tConf["marks."]["DATETEXT."]["value"]=$theLink;
		$tConf["marks."]["FONT"]="HTML";
		$tConf["marks."]["FONT."]["value"]=$config[font];
		$tableRows.=$this->TEMPLATE($tConf);

Eigenes Template calendar.tmpl

<!-- ###TEMPLATE_CALENDAR### -->
	<table border="0" cellpadding="0" cellspacing="0">
	<!-- ###TABLE_CONTENT### -->
		<!-- ###DATE_HEADER### -->
		<tr>
			<td class="calendardate"><p> ###DATE### </p></td>
			<td class="calendarhead"><p> ###HEADER### </p></td>
			<td class="calendardate"><p>  ###DATETEXT### </p></td>

		</tr>
		<!-- ###DATE_HEADER### -->
		<!-- ###DATE_CONTENT### -->
		<tr>
			<td class="calendartime"><p>###TIME###</p></td>
			<td class="calendarcontent"><p>###CONTENT###</p> </td>
		</tr>
		<!-- ###DATE_CONTENT### -->
	<!-- ###TABLE_CONTENT### -->
	</table>
<!-- ###TEMPLATE_CALENDAR### -->

Ausgabe im Frontend:

		<tr>
			<td class="calendardate"><p> 23/03 2005 </p></td>
			<td class="calendarhead"><p> ydf Seiteninhalt </p></td>
			<td class="calendardate"><p>  <a href=index.php?id=></a> </p></td>

		</tr>
		
		<tr>
			<td class="calendartime"><p>20:00</p></td>
			<td class="calendarcontent"><p><b>test einer uhrzeit in einem föllig fremden Teil der homepage</b><BR></p> </td>
		</tr>
		
		<tr>
			<td class="calendardate"><p> 15/08 2005 </p></td>
			<td class="calendarhead"><p> Höftdeich Sommerfest </p></td>
			<td class="calendardate"><p>  <a href=index.php?id=52>Daatumtext</a> </p></td>

		</tr>
		
		<tr>
			<td class="calendartime"><p></p></td>
			<td class="calendarcontent"><p><b>Stammtisch NordWest</b><BR>Der Stammtisch Nord West orgqanisiert ein Sommerfest in den Wümmeniederungen. Ziel ist ein wunderschön gelegenes Haus auf dem Wümmedeich, welches in historischer Bauweise gefertigt wurde.</p> </td>
		</tr>
		
		<tr>
			<td class="calendardate"><p> 12/12 2005 </p></td>
			<td class="calendarhead"><p> Test ob es Zeitlich geordnet wird </p></td>
			<td class="calendardate"><p>  <a href=index.php?id=></a> </p></td>

		</tr>
		
		<tr>
			<td class="calendartime"><p>20:00</p></td>
			<td class="calendarcontent"><p><b>Test</b><BR>das passiert um 20 uhr</p> </td>
		</tr>
		
		<tr>
			<td class="calendartime"><p>15:00</p></td>
			<td class="calendarcontent"><p><b>das passiert um eins</b><BR></p> </td>
		</tr>

Es wird zwar auch ein Link produziert, wenn keine Werte vorhanden sind. Sieht zwar im Code nicht schön aus, aber bevor ich mich an Schleifen waage - und man sieht es im Explorer ja nicht o.O

Wie auch immer, ich bin Stolz auf mein PHP-Ergebnis *schampuskorkenknall* 8-)

Beste Grüße
Torsten