André Laugks: Smarty

Beitrag lesen

Hallo!

Ich habe mir mal die Template-Maschine Smarty installiert. Sieht nett aus aber verdammt kompliziert. Entwerder bin ich zu blöd oder blind (Doku)?

Wie kann man Schleifen bei Smarty einsetzen? Und wenn ich schon einmal was schreibe, wie kann ich Templates verschachteln?

// index.tpl
   -------------------------------------------------------

{include file="kopf.tpl"}

<!--

Und wie setze ich nun hier body.tpl und zeile.tpl ein oder wie
   rufe ich sie in Smarty auf?

-->

{include file="fuss.tpl"}

-------------------------------------------------------

// kopf.tpl
   -------------------------------------------------------
   <html>
   <body>
   -------------------------------------------------------

// body.tpl
   -------------------------------------------------------
   <table>
   {$zeile}
   </table>
   -------------------------------------------------------

// zeile.tpl
   -------------------------------------------------------
   <tr><td>{$X}</td></tr>
   -------------------------------------------------------

// fuss.tpl
   -------------------------------------------------------
   </body>
   </html>
   -------------------------------------------------------

// index.php
require 'Smarty.class.php';
$smarty = new Smarty;
$smarty->caching = false;
$smarty->compile_check = true;
$smarty->debugging = false;

for($i=0;$i<10;$i++)
 {
     $smarty->assign("X",$i);
 }

$smarty->display('index.tpl');

MfG, André Laugks

--
L-Andre @ gmx.de