On Mon, 2007-04-30 at 10:40 +1000, Mathew Robertson wrote:
> > Is there a way to loop from a lower integer to an higher
> > one? For example,
> > say an article has a rating of 4. I'd like to loop from 1 to
> > 4 and print a
> > star at each iteration. The only way I can see of doing this
> > is create an
> > array ref in the perl coder and pass that to the template,
> > which seems a lot
> > of pointless effort
> > I've been trying to think of a way to do that with CSS, since
> > currently I'd like to indent things based on a "level" variable
> > passed through the template (and to complicate things, I'd like to
> > max out at a certain point to avoid right-margin squish, considering
> > that in a couple of cases the threads nest over two hundred levels
> > deep).
> > With (one assumes) a rating system with its own ceiling, though, you
> > could go with img src="blahblah/star<TMPL_VAR name="rating">.gif" or
> > what have you, and just have a set of graphics with star1.gif having
> > one star, star2.gif having two stars, and so forth.
> If you just want to print 4 stars, then just do that. * * * *
> If you are looking for some indentation background, you could try
> something like the following on a div:
> style="background:url('star.gif') right repeat-y;"
> If you are looking for something like <TMPL_FOR 1..4> then you
> probably need to re-evaluate why you need it - maybe you need to re-
> think your original problem. That said, there have been previous
> discussions on whether the TMPL_xxx syntax should support user-defined
> extensions, and various people have their own hacks to allow such a
> feature (which would then allow you to build your TMPL_FOR).
Well my problem is that sometimes I want to iterate through a numeric
range. If an article is ranked 4 stars then the designer can either
iterate through each ranking and display a star or he/she can simply
output "4 stars." (one customer likes the latter, another wants the
former). Likewise, I use Data::Page::Navigation for paginated data -
it's a really nice module, and if it displays 10 indexes at the bottom
of the page, say from 5 - 14, it would be nice if I could iterate
through them rather than doing it in Perl. It's not a religious
decision, it just gives the flexibility to the designers.
> What is the problem you are trying to solve? Someone here might have
> solved it already...
I hope this gives enough info. If I'm doing it wrong, I'm only too
pleased to be told if there's a better way. Michael Peters suggested
possible. I have looked through the docs, and couldn't see anything
obvious, but was hoping that perhaps someone had solved this problem
before me via some kind of logic that I hadn't thought of.