|
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 |
obscur3 Smarty Rookie
Joined: 01 Sep 2012 Posts: 5
|
Posted: Sat Sep 01, 2012 7:23 pm Post subject: Foreach Array voller Objekte |
|
|
Guten Abend,
nachdem ich seid ungefähr 2 Stunden angestrengt versuche herauszufinden, wie ich ein Array voller Objekte mithilfe von {foreach} ausgebe, habe ich aufgegeben und ziehe nun euch zu rate (:
Dies ist der Ausschnitt aus dem Template und hier liegt wahrscheinlich auch der Fehler
Code: |
{foreach $cars as $car}
<li>{$car->producer} {$car->name}</li>
{/foreach}
|
und so übergebe ich die Objekte:
Code: | $smarty->assign('cars', $cars->all()); |
$cars->all gibt das aus:
Code: |
function all() {
$statement = $this->db->prepare("select * from cars");
$statement->execute();
$result = array();
foreach ($statement as $row) {
$result[] = new Car($row);
}
return $result;
}
|
Mein Grundaufbau stimmt , es geht mir nur um den Zugriff. Das Array gibt auch die Daten aus , die ich haben möchte , das habe ich schon getestet.
Ich hoffe ihr könnt mir schnell helfen und jetzt schon mal vielen Dank im Vorraus!
lg obscur3 |
|
Back to top |
|
obscur3 Smarty Rookie
Joined: 01 Sep 2012 Posts: 5
|
Posted: Sun Sep 02, 2012 11:17 am Post subject: |
|
|
Kann mir niemand helfen ? Ich werde mal im englischen Bereich posten. :/ |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
|
Back to top |
|
obscur3 Smarty Rookie
Joined: 01 Sep 2012 Posts: 5
|
Posted: Sun Sep 02, 2012 1:17 pm Post subject: |
|
|
Alles klar. gemerkt für nächste Mal. Vielen Dank für die Antwort. Es hat alles geklappt! |
|
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
|