Hallo André,
einfaches Beispiel:
// 1.tpl
<html><body>{TPL_2} <- hier 2.tpl rein </body></html>// 2.tpl
<table>{TPL_3} <- hier 3.tpl rein</table>// 3.tpl
<tr><td>{TPL_4} <- hier 4.tpl rein</td></tr>// 4.tpl
blablabla
Das geht natürlich auch:
1.tpl:
<html><body>{include file="2.tpl" zeilen=$meinedaten}</body></html>
2.tpl:
<table>{section loop=$zeilen name=zloop}{include file="3.tpl" inhalt=$zeilen[zloop]}{/section}</table>
3.tpl:
<tr><td>{include file="4.tpl" inhalt=$inhalt}</td></tr>
4.tpl:
<b>{$inhalt}</b>
script.php
require 'Smarty.class.php';
$smarty = new Smarty;
$smarty->caching = false;
$smarty->compile_check = true;
$smarty->debugging = false;
$meinArray = array ();
for($i=0;$i<10;$i++)
{
$meinArray[] = $i;
}
$smarty->assign ('meinedaten', $meinArray);
$smarty->display('1.tpl');
Ausgabe:
<html><body><table>
<tr><td><b>0</b></td></tr>
<tr><td><b>1</b></td></tr>
<tr><td><b>2</b></td></tr>
<tr><td><b>3</b></td></tr>
<tr><td><b>4</b></td></tr>
<tr><td><b>5</b></td></tr>
<tr><td><b>6</b></td></tr>
<tr><td><b>7</b></td></tr>
<tr><td><b>8</b></td></tr>
<tr><td><b>9</b></td></tr>
</table></body></html>
Bei der 3.tpl ist das inhalt=$inhalt nicht notwendig, da die Variable ja sowieso so heißt. Allerdings verdeutlicht das das ganze viel mehr.
Viele Grüße,
Christian
| http://www.selflinux.org/ |
| http://aktuell.de.selfhtml.org/tippstricks/beitrag.htm |
| sh:) fo:) ch:] rl:( br:> n4:& ie:% mo:) va:) de:] zu:) fl:( js:| ss:) ls:[ |
| http://emmanuel.dammerer.at/selfcode.html |