Xpath select all items where parent has specific nodename
I'm always struggling to long with XPaths, now again:
For a new umbraco site i've got about 30 products. In my media library I sort it's images in subfolders of a folder with the name of the product.
Product name -- Thumbnails -- HoverImages -- Backgrounds
In my MNTP I want to add a filter based on it's parents nodeName. E.g.: only the images in the 'Backgrounds' may be picked.
If I write: /*[@nodeName='Backgrounds'], the folder 'Backgrounds' can be picked. That right if I use my little XPath knowledge /*[ancestor::*[@nodeName='Backgrounds']] must be the code to get it's children be selectable. Sadly that's not right. What's wrong?
Unfortunately the XPath filters for enabling/disabling a node are only applied to that node itself (and not the entire tree). So you can test for properties on that node specifically, but can not traverse to parent/child nodes.
You could use the @parentID? (Not as flexible as the parent's @nodeName, but could be a workable solution?)
Xpath select all items where parent has specific nodename
I'm always struggling to long with XPaths, now again:
For a new umbraco site i've got about 30 products.
In my media library I sort it's images in subfolders of a folder with the name of the product.
Product name
-- Thumbnails
-- HoverImages
-- Backgrounds
In my MNTP I want to add a filter based on it's parents nodeName.
E.g.: only the images in the 'Backgrounds' may be picked.
If I write: /*[@nodeName='Backgrounds'], the folder 'Backgrounds' can be picked.
That right if I use my little XPath knowledge /*[ancestor::*[@nodeName='Backgrounds']] must be the code to get it's children be selectable. Sadly that's not right. What's wrong?
Thanks in advance.
Hi Gaitano,
Unfortunately the XPath filters for enabling/disabling a node are only applied to that node itself (and not the entire tree). So you can test for properties on that node specifically, but can not traverse to parent/child nodes.
You could use the @parentID? (Not as flexible as the parent's @nodeName, but could be a workable solution?)
Cheers, Lee.
Thx Lee, for clearing this out.
Like you say it yourself: that's nto really flexible.
I think I'll add an extra property to my image: imageType and check on that.
Too bad traversing through parents isn't possible.
It might be possible, but would be quite a big hit on rendering each node on the tree, especially if the tree is large.
Still *if* it is something you feel strongly about, do feel free to raise a ticket over on the issue tracker:
http://issues.umbraco.org/issues/U4#newissue=yes
You never know, others might feel the same and work towards a fix/resolution? :-)
Cheers, Lee.
is working on a reply...