On Thu, 25 Sep 2003 16:38:49 +0200, Ralf Ullrich wrote:
Hi Ralf
See below.
>=3D> $html) and this works fine. but this is bad if you want to=
style
>certain rows in a different way from other rows. But i don't=
know
>how to
>handle this with TMPL_LOOP, since I never can know, how many
>children
>exist for one parent and how deep this hierarchy will be.
>has anyone on this list done something like this and could point=
me
>in
>the right direction?
I see Karen has given you some ideas.
To create a crude tree-like structure within a table, try=
prefixing
the rows with multiple white boxes and then an 'elbow' box.
Demo images:
http://www.deakin.edu.au/~rons/html/black-and-white-boxes.html
This method is trivial, but may help.
Also, learn how to use H::T's __first__ etc tokens to change the=
CSS
class of a <td>, etc. Demo:
=09<tmpl_loop name =3D outer_result_loop>
=09=09<tmpl_if name =3D __first__>
=09=09=09<tr>
=09=09=09=09<tmpl_loop name =3D inner_result_loop>
=09=09=09=09=09<td class =3D "headbox">
=09=09=09=09=09=09<tmpl_var name =3D result_td>
=09=09=09=09=09</td>
=09=09=09=09</tmpl_loop>
=09=09=09</tr>
=09=09<tmpl_else>
=09=09=09<tr>
=09=09=09=09<tmpl_loop name =3D inner_result_loop>
=09=09=09=09=09<td>
=09=09=09=09=09=09<tmpl_var name =3D result_td>
=09=09=09=09=09</td>
=09=09=09=09</tmpl_loop>
=09=09=09</tr>
=09=09</tmpl_if>
=09</tmpl_loop>
--
Ron Savage, rons@... on 26/09/2003. Room EF 312
Deakin University, 221 Burwood Highway, Burwood, VIC 3125,=
Australia
Phone: +61-3-9251 7067, Fax: +61-3-9251 7604
http://www.deakin.edu.au/~rons

On Thu, 25 Sep 2003, Wojciech Pietron wrote:
> I have two nested loops. Is there a way to get the value of
> outer <TMPL_VAR NAME="__counter__"> from inner loop?
No there isn't. But it should be easy to create your own __counter__
workalike and access it normally with global_vars set.
-sam

On Thu, 25 Sep 2003, Ralf Ullrich wrote:
RU>has anyone on this list done something like this and could point me in
RU>the right direction?
H::T doesn't recurse very well, but it does loops nicely. What I end up
doing is putting all messages in a single TMPL_LOOP. The indentation
level is then used to make a dummy TMPL_LOOP within that one, which is
used by the template however it needs to be... at the moment, I think I'm
just using nonbreaking spaces to indent it. You could use clear graphics
to do the same thing.
If you were willing to accept less of a separation between template and
code, you could pass a simple variable instead (level*N), and use it for
the width of a clear graphic, or an empty table cell. Or if you're using
expressions, you could pass the level value as is, and multiply it by the
desired amount within the template.
--
Karen J. Cravens silver@...

> html::template. I get the guestbook-data via DBi from a MySQL-Server.
> I process this data within a recursive function, which calls itself
> until no record has any more children. By now I append all html-data with
First, the part that isn't your question, but I feel opinionated :)
Recursion is expensive. I've done this in two other ways, depending on
my data:
1) Select all data from table (including info on which nodes are
children of others, then sort.)
2) create a list (initially of just the root). Move through this list,
inserting (splice()ing) any children of the current node just after the
current node. This is my preferred method. IT also allows me to store
the "depth" (relative to root) of each node.
> => $html) and this works fine. but this is bad if you want to style
> certain rows in a different way from other rows. But i don't know how to
I just offer my data as a list to my template, which can then style the
output based on the depth of the node (since that is now in the data).
For example, each node usually has (NodeID, Depth, Name, Title, Text,
Date). I can indent or otherwise indicate the depth on a per-row basis,
and all HTML formatting is done in the template.
Hope that helps in some fashion.
--
SwiftOne / Brett Sanger
swiftone@...

hello,
this is my first mail to the list since i began using html::template one
year ago.
i have the following problem:
i have an threaded discussion forum for which I want to use
html::template. I get the guestbook-data via DBi from a MySQL-Server.
I process this data within a recursive function, which calls itself
until no record has any more children. By now I append all html-data with
$html .= $html;
and add it ot html::template as a scalar param ( $t->param('forum_data'
=> $html) and this works fine. but this is bad if you want to style
certain rows in a different way from other rows. But i don't know how to
handle this with TMPL_LOOP, since I never can know, how many children
exist for one parent and how deep this hierarchy will be.
has anyone on this list done something like this and could point me in
the right direction?
Thanks in advance for any help,
Ralf