Hi,

I am trying to write a TT application that will generate a catalogue for my business in Latex.

I am wondering how to approach outputing groups of items to get the desired latex code.

I have catagories and each catagory has products in it, so if i do a query, i get results like:

Catagory             Item
Fresh Fruit          Apples
Fresh Fruit          Oranges
Fresh Fruit          Bananas
Fresh Fruit          Pears
Fresh Vegetables     Peas
Fresh Vegetables     Beans
Fresh Vegetables     Lettuce
Fresh Vegetables     Carrots

now, the trick is, if I use FOREACH loop, how do I know when the catagory changes so I can close my table of items....

[% FOREACH item DBI.query('select Catagory, Item from Products groupby
                 catagory')
  [% IF catagory <> item.catagory %]
      new catagory [% item.catagory %]
      [% catagory = item.catagory %]
      \begin{longtable}[l][r] \hline
      [% item.item %] \\
  [% ELSE %]
      [% item.item %]  \\
  [% END %]

The problem is closing the \begin{longtable}. Where do I close it? is there a nice way handling groups of items in TT?

Can I use the get_next method from Iterator shomehow to detect the catagory of the next item, and output a closing longtable if its changed?

I need the output to look something like:

\section{Fresh Fruit}
\begin{longtable}
Apples\\
Oranges\\
Bananas\\
Pears\\
\end{longtable}     <-------------- this is the line im having trouble with
\section{Fresh Vegetables}
\begin{longtable}
Peas\\
Beans\\
Lettuce\\
Carrots\\
\end{longtable}



Any suggestions greatly appreciated.

Jason
--



Jason Lewis
-------------------------------------------------
please note my new email address [EMAIL PROTECTED]


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

Reply via email to