Showing an fallback images on page where no other images is selected
Hi
I have a problem in my xslt fil. I try to insert a images on a suppage. If there is selected an images on the currentpage, the this should be used but if there isen't selected an images, then an images from the level above should be used.
You can simply use a choose statement to check if the image is selected, and if not, use the image from the parent node. I extracted your media code into a template to reduce duplication:
I know I said that I wanted to get the images from the level above. But I just realised that if level1 has a images and level2 and level3 does not have an images I what them both to get the images from level1.
The way it works now is that it only gets the images from the level above = level2 gets the images from level1, level3 gets this Error parsing XSLT file: \xslt\TopSlider.xslt
Ah, that makes sense. This code assumes the parent will always have an image. I think what you're looking for is to recursively look for an image - that is, check each parent until we find an image.
To get a property recursively in XSLT, you can use:
<xsl:template match="/"> <xsl:apply-templates select="$currentPage/ancestor-or-self::*[normalize-space(topBilledeSubPages)][1]/topBilledeSubPages" /> <!-- This will find the first parent (or current page) where topBilledeSubpages has a value, then "pass it in" to the template below --> </xsl:template>
Showing an fallback images on page where no other images is selected
Hi
I have a problem in my xslt fil.
I try to insert a images on a suppage.
If there is selected an images on the currentpage, the this should be used but if there isen't selected an images, then an images from the level above should be used.
Does it make any sense?
This is what I got so fare.
Hope someone can help :-)
Hi Kate,
You can simply use a choose statement to check if the image is selected, and if not, use the image from the parent node. I extracted your media code into a template to reduce duplication:
Hope this helps,
Tom
Hi Tom
I think Im almost there now.
So fare I got this
I know I said that I wanted to get the images from the level above. But I just realised that if level1 has a images and level2 and level3 does not have an images I what them both to get the images from level1.
The way it works now is that it only gets the images from the level above = level2 gets the images from level1, level3 gets this Error parsing XSLT file: \xslt\TopSlider.xslt
Hope you still have time to help
Kate
Hi Kate,
Ah, that makes sense. This code assumes the parent will always have an image. I think what you're looking for is to recursively look for an image - that is, check each parent until we find an image.
To get a property recursively in XSLT, you can use:
Here's what I might do in your code:
Hope this helps,
Tom
It works perfectly.
Thanks for your help :-)
is working on a reply...