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

While-Schleife

 
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
Philipp_Frank
Smarty Rookie


Joined: 24 Oct 2004
Posts: 6

PostPosted: Sun Oct 24, 2004 9:31 pm    Post subject: While-Schleife Reply with quote

Hi, ich habe folgendes Problem:
Ich nutze diesen Code um alle ordner/dateien aus einem Ordner auszulesen und in ein selectfeld zu schreiben:
Code:
<?PHP
if ($dir = @opendir("EXTgalerie/galerien/")) {
  while (($file = readdir($dir)) !== false) {
    if($file != ".." && $file != ".")
      $filelist[] = $file;
    }
  closedir($dir);
}
asort($filelist);
while (list ($key, $val) = each ($filelist))
  echo "<option value=\"$val\">$val</option>";
?>

Wie mache ich das denn nun in einem template. Bin noch neuling im Bezug auf smarty Very Happy
Back to top
View user's profile Send private message
b166-er
Smarty Rookie


Joined: 22 Oct 2004
Posts: 29
Location: Germany, Wiesbaden

PostPosted: Mon Oct 25, 2004 5:13 am    Post subject: Reply with quote

bei diesem beispiel is-es gaaanz einfach Smile

hier schau ma:

erstma deine php-datei:
[php]<?php
...
$smarty_obj = new Smarty; // hier erstma Smarty instanzieren
...// dann noch paar configs an Smarty uebergeben

// hier kommt dein code
if ($dir = @opendir("EXTgalerie/galerien/")) {
while (($file = readdir($dir)) !== false) {
if($file != ".." && $file != ".")
$filelist[]['name'] = $file;
}
closedir($dir);
}
asort($filelist);

// jetzt einfach die liste mit dateien an smarty uebergeben:
$smarty_obj->assign('ordnerliste',$filelist);

// und letzten endes, das template anzeigen.
$smarty_obj->display('index.tpl');
?>[/php]

jetzt das template, index.tpl:
Code:
... // html-code
{section name=f1 loop=$ordnerliste}
<option value="{$ordnerliste[f1].name}">{$ordnerliste[f1].name}</option>
{/section}


thats it! Smile

das ist eine von vielen methoden...
viel spass, cu
________
COLORADO DISPENSARY
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