In my xslt file I have some plain html that looks like this: <li class="" style="background:url(images/prop1.gif) no-repeat;">Text content</li> <li class="" style="background:url(images/prop2.gif) no-repeat;">Lorem Ipsum</li> <li class="" style="background:url(images/prop3.gif) no-repeat;">Lorem Ipsum</li> <li class="" style="background:url(images/prop4.gif) no-repeat;">Lorem Ipsum</li>
Nowmy question is, can iloop througheach <li> using <xsl:for-eachselect="...."> ... </xsl:for-each>
I need to change the background-images and text in each <li> from Content. The code I got so fare for this is like below, but I dont know how to make the loop. I know that it always has to loop through the list 4 times.
In XSLT you practically never need to just count from 1 to X to do something; You're pretty much always doing something to a chunk of data, which is exactly what you have here too; You have four pieces of content that happen to be named ikon1, ikon2 etc.
XSLT works with by creating templates for content, so all you have to do is create a template with the desired output and then make sure to use that template for all four fields, e.g.:
(If you want to, you can use <xsl:template match="ikon1 | ikon2 | ikon3 | ikon4"> instead of the substring thing - same with the select of the <xsl:apply-templates />)
making a loop
Hi
In my xslt file I have some plain html that looks like this:
<li class="" style="background:url(images/prop1.gif) no-repeat;">Text content</li>
<li class="" style="background:url(images/prop2.gif) no-repeat;">Lorem Ipsum</li>
<li class="" style="background:url(images/prop3.gif) no-repeat;">Lorem Ipsum</li>
<li class="" style="background:url(images/prop4.gif) no-repeat;">Lorem Ipsum</li>
Now my question is, can i loop through each <li> using
<xsl:for-each select="....">
...
</xsl:for-each>
I need to change the background-images and text in each <li> from Content. The code I got so fare for this is like below, but I dont know how to make the loop.
I know that it always has to loop through the list 4 times.
Hope it makes sense
/Kate
Is it possible to make anything like this in umbraco/xslt file?
what version of Umbraco are you using, and is there a chance of using razor instead of xslt? Your required loop would be trivial to write then.
Hi Kate,
With this code you should loop through all the nodes with a specific document type.
Hope this can help you.
/Dennis
Hi Dennis
it's not quite what I need.
I need it to count 1 up each time it runs through the loop so that ikon1 become ikon2, ikon3...
I think I have to take a look at the razor thing :-)
Andrew - the umbraco is version 4.11.10 and I have now ideen on how to use razor. Can you give me a hint on were to start?
/Kate
Hi Kate,
In XSLT you practically never need to just count from 1 to X to do something; You're pretty much always doing something to a chunk of data, which is exactly what you have here too; You have four pieces of content that happen to be named ikon1, ikon2 etc.
XSLT works with by creating templates for content, so all you have to do is create a template with the desired output and then make sure to use that template for all four fields, e.g.:
No need to do any counting for that :-)
(If you want to, you can use
<xsl:template match="ikon1 | ikon2 | ikon3 | ikon4">
instead of the substring thing - same with theselect
of the<xsl:apply-templates />
)/Chriztian
Thanks Chriztian.
I will try that :-)
is working on a reply...