Check whether any parent or ancestors contain a property
Hi,
I have an Umbraco V4 website and I have the following XSLT which checks if the parent page has a property (an image in this case) and if so it displays this property. Currently the code I have works but if I was to add a sub page then I would have modify the XSLT to make it check the parent of the parent of the parent page to see if it has that property. I was thinking there must be a way to just check in any of the ancestor pages contains the property and if so then show it. Can anyone help me with how I might need to modify my code?
I do need the when statement in there though because the XSLT is supposed to display the image "middlebannerimage" if there is one specified in the current page or any of its ancestors but if not it will show a flash file that I am calling in "otherwise" statement (I left that part out of the XSLT I put in my original XSLT to try and reduce the size of it). The full XSLT I have is as follows:
You ask for help modifying your code - here's a couple of pointers:
Get rid of all the repetition (you'll hate it a month from now when you need to change something) - create a separate template for the stuff you do multiple times
Cache the result from umbraco.library:GetMedia() in a variable and use that to access the data
Applying these to your code, I've shrunk the XSLT to this:
PS: Don't know if the two empty <div>s after the <script> are supposed to be empty (could be stripped code to avoid cluttering), but if they are indeed intended to be empty, you'll have to use <xsl:comment> instead of a regular XML comment, because regular comments in the stylesheet are just that, and won't make it through the tunnel to the output...
Check whether any parent or ancestors contain a property
Hi,
I have an Umbraco V4 website and I have the following XSLT which checks if the parent page has a property (an image in this case) and if so it displays this property. Currently the code I have works but if I was to add a sub page then I would have modify the XSLT to make it check the parent of the parent of the parent page to see if it has that property. I was thinking there must be a way to just check in any of the ancestor pages contains the property and if so then show it. Can anyone help me with how I might need to modify my code?
Hows about instead of
parent::node
using
anscestor::node
Dan
Hi Dan,
I tried that with the correct spelling :-)
But it did not work :-(
I got an XSLT error on the child pages.
Boo typos.
Hows about this instead of all the chooses
I must admit to not being sure it will work, and not having enough time to test it
Dan
I do need the when statement in there though because the XSLT is supposed to display the image "middlebannerimage" if there is one specified in the current page or any of its ancestors but if not it will show a flash file that I am calling in "otherwise" statement (I left that part out of the XSLT I put in my original XSLT to try and reduce the size of it). The full XSLT I have is as follows:
Hi,
You ask for help modifying your code - here's a couple of pointers:
PS: Don't know if the two empty <div>s after the <script> are supposed to be empty (could be stripped code to avoid cluttering), but if they are indeed intended to be empty, you'll have to use <xsl:comment> instead of a regular XML comment, because regular comments in the stylesheet are just that, and won't make it through the tunnel to the output...
is working on a reply...