|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
the-styler Smarty Rookie
Joined: 12 Jul 2004 Posts: 25
|
Posted: Mon Jul 12, 2004 6:38 pm Post subject: Wie setze ich das in smarty um? |
|
|
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 |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Jul 12, 2004 7:29 pm Post subject: |
|
|
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 |
|
the-styler Smarty Rookie
Joined: 12 Jul 2004 Posts: 25
|
Posted: Mon Jul 12, 2004 8:22 pm Post subject: |
|
|
danke, du hast mich auf den richtigen weg gebracht |
|
Back to top |
|
|
|
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
|