larsen has asked for the wisdom of the Perl Monks concerning the following question:

I have problems with the following snippet (it's a template file that is meant to be used with ttree (see Template)).

[% USE DBI %] [% DBI.connect( 'dbi:mysql:personal', 'root', '' ) %] [% query_category = DBI.prepare('select category from link group by ca +tegory') %] [% query_link = DBI.prepare('select * from link where category = ?') % +] [% FOREACH item = query_category.execute() %] [% FILTER redirect("links/${item.category}.html") %] [% INCLUDE header.tt2 %] [% FOREACH link = query_link.execute( $item.category ) %] ... do something ... [% END %] [% INCLUDE footer.tt2 %] [% END %] [% END %]

As you can see, I have two nested FOREACH instructions that cycle with different iterators. The inner cycle depends on $item.category's value. The problems is that every links/${item.category}.html page it's empty, apart for header and footer stuff. $item.category is passed correctly, and the database is not empty. I'm working with ttree 2.03 (Template Toolkit 2.00). Suggestions?

Replies are listed 'Best First'.
Re: Problems with Template Toolkit and ttree
by larsen (Parson) on Aug 19, 2001 at 16:58 UTC
    Rats! Just my fault!
    This line

    [% FOREACH link = query_link.execute( $item.category )  %]

    should be

    [% FOREACH link = query_link.execute( item.category )  %]