[ic] Looping with alternate row

Paul Jordan paul at gishnetwork.com
Tue Sep 16 11:18:59 EDT 2003


> --On 16.09.2003 17:05 +0200 Juergen R. Plasser wrote:
> > How can I perform this tags right (in a [search-list]):
> > [if value [item-increment] == 10]<p>This is 10</p>[/if]
> > How can I compare the [item-increment] modulo 10 == 1?
> > Seems that I have to dive into perl...
>
> I have tried something like
>
>     [if explicit]
>     [condition]
>         $inc = '[item-increment]';
>         return 1 if ($inc % 10) == 1;
>         return 0;
>     [/condition]
>     This is 10.
>     [else]
>     This is not 10.
>     [/else]
>     [/if]
>
> and it works...
>
> Thanx,
> Jürgen


Yes, just incase this changes your approach, I believe you would need to
compare it as 10 == 01 to have an accurate outcome with your original [if]
idea. I have had to do this type of thing several times. If item-increment was
zero padded, it would help. However without knowing your end application... For
example prefix-alternate & prefix-last may help you as well. As for efficiency,
who knows which is better, but when I do the above i always feel running so
many conditions is such a waste when all you want is to display something once
:)

I had been contemplating having changes made to these but didn't know if anyone
would get use out of it. For example, a tag that ran only once [prefix-once
10]you are number 10[/prefix-once] but doesn't repeat like prefix-alternate.
Infact it could be a attribute for prefix-alternate [prefix-alternate .10] '.'
meaning only once.

This type of thing comes in handy when you need to highlight a specific object,
like as in a calendar.


Paul




More information about the interchange-users mailing list