List Info

Thread: NXSL and alternating row color




NXSL and alternating row color
user name
2006-03-06 21:54:35
I'm trying to use the NXSL API to display a list of items
similar to an
RSS feed as in the google blog example at
h
ttp://www.google.com/apis/homepage/guide.html#NXSL

I want to be able to alternate the column color and put the
item number
next to each row, but that info is not implicit in the XML
I'm parsing.

Is there any way to get an alternating mechanism or the
current
iteration count via the NXSL template?

Paul


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Google Homepage API" group.
To post to this group, send email to Google-Homepage-APIgooglegroups.com
To unsubscribe from this group, send email to
Google-Homepage-API-unsubscribegooglegroups.com
For more options, visit this group at ht
tp://groups.google.com/group/Google-Homepage-API
-~----------~----~----~----~------~----~------~--~---

NXSL and alternating row color
user name
2006-03-06 22:28:05
That's an excellent question. As far as I can see, you have
to use a
hack, the as of now undocumented XPath extension function
ext-if().
Here is how:

  <div select="item"
values="class:ext-if(position() mod 2 =
0,'white','green')">...</div>

This will create as many divs as your input document has
<item>
elements. Every even numbered div will get the CSS class
"white", the
odd numbered ones the CSS class "green".

Beware that XPath starts couning things at 1, that is, the
value of
position() for the first element matched by the expression
in the
select attribute will be 1, not 0. So the first div will be
class="green".

As you can easily guess from the example, the ext-if()
function takes
three arguments. If the first argument evaluates to boolean
true, then
it returns the value of its second argument, otherwise it
returns the
value of its third argument.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Google Homepage API" group.
To post to this group, send email to Google-Homepage-APIgooglegroups.com
To unsubscribe from this group, send email to
Google-Homepage-API-unsubscribegooglegroups.com
For more options, visit this group at ht
tp://groups.google.com/group/Google-Homepage-API
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )