I have 4 Media Picker items in a document type (SlideImage1, SlideImage2, SlideImage3 and SlideImage4). I would like to be able to show every image out of those 4, so if 1 exists, only show 1, if 2 exists, show 2 etc. If 1, 2, 3, 4 exists then show all of them.
What's the easiest way to check if 2, 3 or 4 exists? About future proofing, is there a way to check if another alias is added (a 5th item) and to automatically add that in?
The apply-templates line takes care of selecting all properties with a name starting with 'SlideImage' - the template below does the rendering of each of those. Future-proof already :-)
Apologies,I should've posted my code as I am using a variable $sharedNode which is grabbing the images from another document. My old code is as follows below, so I guess I also need to call the $sharedNode variable, just not sure on the syntax (not great with XPath).
How do I add the sharedNode variable into this example?
For-each - image
I have 4 Media Picker items in a document type (SlideImage1, SlideImage2, SlideImage3 and SlideImage4). I would like to be able to show every image out of those 4, so if 1 exists, only show 1, if 2 exists, show 2 etc. If 1, 2, 3, 4 exists then show all of them.
What's the easiest way to check if 2, 3 or 4 exists? About future proofing, is there a way to check if another alias is added (a 5th item) and to automatically add that in?
Thanks
Hi Devin,
This is exactly the job of match templates in XSLT:
Hope that gets you going!
/Chriztian
Hi Chriztian,
That's great thanks. I know you can only pass one value here though so what about SlideImage2, 3 and 4?
Hi Devin,
You didn't try it, did you? :)
The apply-templates line takes care of selecting all properties with a name starting with 'SlideImage' - the template below does the rendering of each of those. Future-proof already :-)
/Chriztian
Hi :)
Apologies,I should've posted my code as I am using a variable $sharedNode which is grabbing the images from another document. My old code is as follows below, so I guess I also need to call the $sharedNode variable, just not sure on the syntax (not great with XPath).
How do I add the sharedNode variable into this example?
Thanks for your help, makes complete sense though.
It's ok figured it out. When applying the template, I just had to change $currentPage to $sharedNode.
Thanks so much Chriztian :)
Awesome - you're welcome :-)
is working on a reply...