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

Reply via email to