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

Loop in Loop wie ?

 
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
Maxcube
Smarty n00b


Joined: 28 Jul 2004
Posts: 3

PostPosted: Wed Jul 28, 2004 9:54 pm    Post subject: Loop in Loop wie ? Reply with quote

Hi,
ich bin neu bei Smarty und kenne mich damit noch nicht so recht aus.
Kann mir bitte einer erklären wie ich einen Loop in einen Loop mache ?

mfg.
Maxcube
Back to top
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Thu Jul 29, 2004 7:14 am    Post subject: Reply with quote

schau hier ma rein:
http://smarty.php.net/manual/en/language.function.section.php

Quote:

Example 7-18. nested sections

{* sections can be nested as deep as you like. With nested sections,
you can access complex data structures, such as multi-dimensional
arrays. In this example, $contact_type[customer] is an array of
contact types for the current customer. *}
{section name=customer loop=$custid}
id: {$custid[customer]}<br>
name: {$name[customer]}<br>
address: {$address[customer]}<br>
{section name=contact loop=$contact_type[customer]}
{$contact_type[customer][contact]}: {$contact_info[customer][contact]}<br>
{/section}
<p>
{/section}


OUTPUT:

id: 1000<br>
name: John Smith<br>
address: 253 N 45th<br>
home phone: 555-555-5555<br>
cell phone: 555-555-5555<br>
e-mail: john@mydomain.com<br>
<p>
id: 1001<br>
name: Jack Jones<br>
address: 417 Mulberry ln<br>
home phone: 555-555-5555<br>
cell phone: 555-555-5555<br>
e-mail: jack@mydomain.com<br>
<p>
id: 1002<br>
name: Jane Munson<br>
address: 5605 apple st<br>
home phone: 555-555-5555<br>
cell phone: 555-555-5555<br>
e-mail: jane@mydomain.com<br>
<p>

Back to top
View user's profile Send private message
Maxcube
Smarty n00b


Joined: 28 Jul 2004
Posts: 3

PostPosted: Thu Jul 29, 2004 9:01 am    Post subject: Reply with quote

Danke, dies habe ich auch schon gefunden, aber leider habe ich dies nicht so recht verstanden, wie ich dies dann in PHP umsetzen/schreiben soll.. Sad.

mfg.
Maxcube
Back to top
View user's profile Send private message
electr0n
Smarty Rookie


Joined: 26 Mar 2004
Posts: 32
Location: Germany

PostPosted: Thu Jul 29, 2004 12:41 pm    Post subject: Reply with quote

In PHP kannst du sowas folgendermaßen anlegen:
[php:1:4906139340]<?php
$smarty_daten = array();
$query = mysql_query(...);
while ($daten = mysql_fetch_assoc($query)) {
$smarty_daten[] = $daten;
}
$smarty->assign('daten', $smarty_daten);
?>[/php:1:4906139340]

Beispielstemplate:
Code:
{foreach from=$daten item=news}
Geschrieben von {$news.autor}<br />
{$news.text}
<hr />
{/foreach}

Diesbezüglich steht eigentlich alles in der Dokumentation.
Back to top
View user's profile Send private message
Maxcube
Smarty n00b


Joined: 28 Jul 2004
Posts: 3

PostPosted: Thu Jul 29, 2004 12:45 pm    Post subject: Reply with quote

danke
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