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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.