Re: [SMARTY] Output of an Array variable in an object
| From: | Manfred Stienstra | Date: | Wed, 13 Nov 2002 19:00:29 +0000 |
| Subject: | Re: [SMARTY] Output of an Array variable in an object | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6422@lists.php.net to get a copy of this message | ||
On Wednesday 13 November 2002 16:30, Kai-Uwe Beyer wrote:
> - $movieList[i] array of Elements like $title,$date,$rate etc. with
> getter and setter functions (get_title())
>
> Now i want to move some elements of movieList (from i=1 to
> count($movieList) in a teble of a template.
> What is the best solution for it. Assign the object to the template or
> an array?
> Where will the loop be? In the template or better than in the php File.
in php:
$movieList = whatever_to_do_to_get_the_list();
$smarty->assign('movielist', $movieList);
$smarty->display('list');
in smarty (list.tpl):
{foreach from=$movieList item=movie}
<p>
{$movie.title} {$movie.date} {$movie.rate}
</p>
{/foreach}
> Is this possible:
>
> <loop>
> $smarty->display('template.tpl');
> </loop>
>
> template.tpl is an include template of the main.tpl an will repeat i
> times.
That is not possible, I mean that is possible, but that is not the proper way
to use smarty.
Manfred