Re: [SMARTY] Newbie question
| From: | Darryl Bleau | Date: | Fri, 10 Jan 2003 21:10:54 +0000 |
| Subject: | Re: [SMARTY] Newbie question | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7121@lists.php.net to get a copy of this message | ||
You might also want to take a look at doing this in a more 'smarty' style,
using sections. Something like:
Index.php
(loop code)
array_push($db_rows, $myrow[0]);
(end loop)
$smarty->assign("LoopRows",$db_rows);
index.tpl
(extra stuff ...)
<Table>
{section name=loopme loop=$LoopRows}
<tr><td>$LoopRows[loopme]</td></tr>
{/section}
</Table>
> Index.php
> (code that retrieves a mysql recordset and loops through the records)
> $html_result .= "<TR><TD>".$myrow[0]."</TD></TR>";
> (end of looping)
>
> if ($html_result = "")
> {
> $html_result = "{#nodata#}";
> }
>
> $smarty->assign("htmlResult", $html_result);
> $smarty->assign("languagefile", "en.txt");
> $smarty->display("index.tpl");
>
> index.tpl
> {config_load file=$languagefile}
> <HTML>
> <BODY>
> <TABLE>
> {$htmlResult}
> </TABLE>
> </HTML>