Loop through thumbnails of node, then thumbnails of subnodes
Hi,
As with most of my XSLT exploits, I've almost got this working, but just require that final nudge!
I'm looping through a content node called media, picking out a thumbnail image for each media album. I need to be able to then show thumbnails for each subnode, so I end up with an output like this:
The code I have currently loops through the parent nodes, gets the image for each and loops through the child nodes. What I'm struggling with is getting the images from the child nodes:
There's an XSLT error when I run this from the website (although the macro doesn't error when I save it). It's something to do with the line which gets the source for the subnode images:
Basically, there's a problem with the "data[@alias='GalleryImage']" - either it doesn't have any data, or doesn't contain an 'umbracoFile' property? Try outputting the value directly, to debug it:
Thanks Lee, that's a handy blog post, so I'll make sure to implement that for my media items in future. I'm not convinced that is the issue here though as primarily I'm using dummy data so there's not much of it there, but it's definitely all there in terms of media items. I tried it anyhow and it's now not erroring in the render, but it's also not returning anything. I'm very sure it must be to do with the way I'm calling "current()" in the nested list - how would it know that I mean the current nested node as opposed to the current parent node?
@Dan (Bristol) - The current() function is contextual. So if you are nested within multiple for-each loops - then it will be using the current node at that point. If you need to reference a parent node, then either store it in a variable - or use some XPath to call the "parent::node".
In terms of debugging, just try outputting something before/after various steps - checking what the value is of variables/nodes.
Ah-ha! So I learn another lesson: aliases are case sensitive. Thanks for your help folks, my original code did actually work - it's just that the alias wasn't quite in the right case.
Loop through thumbnails of node, then thumbnails of subnodes
Hi,
As with most of my XSLT exploits, I've almost got this working, but just require that final nudge!
I'm looping through a content node called media, picking out a thumbnail image for each media album. I need to be able to then show thumbnails for each subnode, so I end up with an output like this:
The code I have currently loops through the parent nodes, gets the image for each and loops through the child nodes. What I'm struggling with is getting the images from the child nodes:
There's an XSLT error when I run this from the website (although the macro doesn't error when I save it). It's something to do with the line which gets the source for the subnode images:
Can anyone see where I'm going wrong?
Thanks!
Hi Dan,
I wrote a blog post a while back about how to "safely" get images from the GetMedia call.
http://blog.leekelleher.com/2009/11/30/how-to-use-umbraco-library-getmedia-in-xslt/
Basically, there's a problem with the "data[@alias='GalleryImage']" - either it doesn't have any data, or doesn't contain an 'umbracoFile' property? Try outputting the value directly, to debug it:
Cheers, Lee.
Thanks Lee, that's a handy blog post, so I'll make sure to implement that for my media items in future. I'm not convinced that is the issue here though as primarily I'm using dummy data so there's not much of it there, but it's definitely all there in terms of media items. I tried it anyhow and it's now not erroring in the render, but it's also not returning anything. I'm very sure it must be to do with the way I'm calling "current()" in the nested list - how would it know that I mean the current nested node as opposed to the current parent node?
My modified code for the nested lists is:
What error do you get if you append
?umbdebugshowtrace=true
to the URL?
Dan
@Dan (Bristol) - The current() function is contextual. So if you are nested within multiple for-each loops - then it will be using the current node at that point. If you need to reference a parent node, then either store it in a variable - or use some XPath to call the "parent::node".
In terms of debugging, just try outputting something before/after various steps - checking what the value is of variables/nodes.
Cheers, Lee.
Ah-ha! So I learn another lesson: aliases are case sensitive. Thanks for your help folks, my original code did actually work - it's just that the alias wasn't quite in the right case.
Ace, glad that you got it sorted in the end!
Cheers, Lee.
is working on a reply...