Log in

View Full Version : Possible to count number of loops through a template?


vasudeva
05-22-2005, 05:41 PM
I'm trying to customize the navbar breadcrumb bit, which by default looks like:
Sitename > Forum > Forumname > Threadname

I want it to look more like a stair-step layout, like:

Sitename
-Forum
-Forumname
-Threadname

Which is how the breadcrumb looks if you hit the 'Show Printable Page' link on a thread, like this (https://vborg.vbsupport.ru/printthread.php?t=81867).

I can't think of a way to do it in CSS -- that is, assign an increasingly right-positioned class to each successive div -- because the navbar template calls the navbar_link template which just generically outputs code for each link portion, making them all the same.

It would be perfect if there was some way to insert a counter in the navbar_link template, and increase it by 1 on every pass through when called for a given instance of the navbar template, because then I could do something like class="navbar_$counter" and then have 3 or 4 classes, .navbar_counter1 through .navbar_counter4, each with an increasingly larger right-position. But I suspect this isn't possible.

Is it?

(I tried hardcoding the navbar code right into the navbar template so I could control the classes used, but then realized this isn't as portable as I'd like. For example, I'd have to also make it aware of the breadcrumb used in the usercp pages.)

akanevsky
05-22-2005, 08:15 PM
I wouldn't do an increasingly right positioned class in css...

I'd make a
style="margin-left: $increasedmarginvalue".
And I would parse the value within php script.

vasudeva
05-22-2005, 08:38 PM
I wouldn't do an increasingly right positioned class in css...

I'd make a
style="margin-left: $increasedmarginvalue".
And I would parse the value within php script.

I could, but I'd rather keep my edits at the template/CSS level, if possible. Feels more contained, I guess.

akanevsky
05-22-2005, 08:59 PM
I'd say that is impossible. Because you would have to change the CSS everytime, and that means you would have to re-include the CSS code everytime, which would be buggy and less "contained" in total.

vasudeva
05-22-2005, 09:17 PM
I'd say that is impossible. Because you would have to change the CSS everytime, and that means you would have to re-include the CSS code everytime, which would be buggy and less "contained" in total.

Yes. So, can I take this emphasis on CSS vs PHP to indicate that there is no built-in facility to detect how many times one template calls another? VB always surprises me with the set of variables it makes available, but I'm not holding my breath on this one.