Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Wie setze ich das in smarty um?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
the-styler
Smarty Rookie


Joined: 12 Jul 2004
Posts: 25

PostPosted: Mon Jul 12, 2004 6:38 pm    Post subject: Wie setze ich das in smarty um? Reply with quote

Ich bin wie warscheinlich viele hier gerade dabei mein System auf smarty umzustellen. Jetzt habe ich folgenden Code vorher genutzt:

[php:1:82604ff4c1]<?php

$tage = array("Sonntag","Montag","Dienstag","Mittwoch", "Donnerstag","Freitag","Samstag");

$abfrage = "SELECT tvguide.zeit AS zeit, episodenguide.de_name AS name, episodenguide.code AS code FROM episodenguide, tvguide WHERE episodenguide.id = tvguide.episoden_id AND tvguide.zeit >= $site[today] AND sender = '1' ORDER BY tvguide.zeit LIMIT 2";
$ergebnis = mysql_query($abfrage);
while($row = mysql_fetch_object($ergebnis))
{
$tag = date("w",$row->zeit);
$uhrzeit = date("H:i",$row->zeit);
if(date(d,$row->zeit) == date(d,$site['today']) AND date(H,$row->zeit) >= date(H,$site['today'])) $day = "Heute";
elseif(date(d,$row->zeit) == date(d,$site['today'] + 86400)) $day = "Morgen";
else $day = $tage[$tag];

eval ("\$tvguide .= \"".loadtpl("tvguide_tag")."\";");
}

?>[/php:1:82604ff4c1]

Wie schreibe ich das um damit es mit smarty funktioniert.
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Mon Jul 12, 2004 7:29 pm    Post subject: Reply with quote

Ohne dein DB-Schema und loadtpl() zu kennen:

Mach deinen Query, baue aus dem Ergebnis ein Array mit 0..n-1 Einträgen.
Jeder Eintrag ist eine $row und enthält die Felder aus dem Select-Ergebnis plus ein paar "ausgerechneter" (wie z.b. $row['tag'] = 'Heute') Werte.

Aann assignst du dieses Array und gibst mit einer {foreach} schleife im Template aus.

Das würde ich in smarty als "den kanonischen Weg" bezeichnen.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
the-styler
Smarty Rookie


Joined: 12 Jul 2004
Posts: 25

PostPosted: Mon Jul 12, 2004 8:22 pm    Post subject: Reply with quote

danke, du hast mich auf den richtigen weg gebracht Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP