I have a page that has a slideshow on it that I'd like to use the first image in the slideshow to display in some other summary. Anyways, what is the best *logic* for doing this.. I know I can hack something together but I'd like to know if you would do this (pseduocode):
Page
-slideshow
--image
--image
--image
if count(images)>=1 then
for-each image
if position=1 then
use this image
OR is there some way to xpath the first image node and just check and use that without a for loop?
You shouldn't need to loop through all the images to find the first one, you should be able to use position=1 in your xpath to just grab the first one.
Thanks that worked perfectly. Still a little new at the xlst stuff. One more thing, if I want to select the first one based on a sortOrder (numeric attribute), am I forced to use the for-each or a template match? It looks that way to me...
edit: I think I've answered my own question.. I just need to check the attribute for sortOrder=1 or whatever (user just needs to know to make sure this is a sortOrder=1)...
Get First Child Node
I have a page that has a slideshow on it that I'd like to use the first image in the slideshow to display in some other summary. Anyways, what is the best *logic* for doing this.. I know I can hack something together but I'd like to know if you would do this (pseduocode):
Hey lucuma,
You shouldn't need to loop through all the images to find the first one, you should be able to use position=1 in your xpath to just grab the first one.
Rich
Thanks that worked perfectly. Still a little new at the xlst stuff. One more thing, if I want to select the first one based on a sortOrder (numeric attribute), am I forced to use the for-each or a template match? It looks that way to me...
edit: I think I've answered my own question.. I just need to check the attribute for sortOrder=1 or whatever (user just needs to know to make sure this is a sortOrder=1)...
<xsl:if test="$projectinfo//slideShowImage [sortOrder=1]!=''">
<img width="288" height="185" alt="">
<xsl:attribute name="src" >
<xsl:value-of select="$projectinfo//slideShowImage [sortOrder=1] /umbracoFile" />
</xsl:attribute>
</img>
</xsl:if>
You should double check if sortOrder isn't a zero-based value ;-)
is working on a reply...