Whenever I have passed an array like yours, I have found it best to push an 
anonymous hash like this

push @emails, { from => "fred", to => "wilma", subj => $subj , date => 
"today"};

and then pass the array to the template with a slash.

my $vars = {
         message  => "Hello World\n",
         emaillist => [EMAIL PROTECTED]
};

Your template looks fine,
Sean

On Tuesday 19 October 2004 12:03 pm, Brandon Hall wrote:
> Hello list,
>
> I've been attempting to create a data structure to store a list of
> emails and display them in the template. I think my problem is in the
> data structure, but I haven't been able to get it right. If someone
> could correct my code, I think I can figure the rest out.
>
> Here is how things look. The problem must be in my 'push' line below
> or in how i pass it to TT2.
>
>     $sth = $dbh->prepare("SELECT distinct filename from email where
> company_id = 3");
>     $sth->execute();
>     while ( @ref = $sth->fetchrow_array ) {
>         #print "$ref[0]\n";
>         $subj = &get_email_subj($ref[0]);
>         $subj = "<a
> href=\"crm.pl?action=show_email&file=$ref[0]\">$subj</a>"; push @emails, [{
> from => "fred", to => "wilma", subj => $subj , date => "today"}];
>     }
>
>
>     my $file = 'show_company.tpl';
>     my $vars = {
>         message  => "Hello World\n",
>         emaillist => @emails
>     };
>
>
> template:
>  [% FOREACH email IN emaillist %]
>   <tr >
>     <td >[% email.from %]</td>
>     <td >[% email.to %]</td>
>     <td >[% email.subj %]</td>
>     <td >[% email.date %]</td>
>   </tr>
>  [% END %]
>
> tia.
>
> _______________________________________________
> templates mailing list
> [EMAIL PROTECTED]
> http://lists.template-toolkit.org/mailman/listinfo/templates

-- 
Sean Kellogg
2nd Year - University of Washington School of Law
GPSS Senator - Student Bar Association
Editor-at-Large - National ACS Blog [http://www.acsblog.org]
c: 206.498.8207    e: [EMAIL PROTECTED]

"Use what talents you possess: the woods would be very silent if no birds
sang there except those that sang best."
              -- Henry Van Dyke

_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to