Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gaitano Boeraeve 17 posts 56 karma points
    Dec 21, 2012 @ 11:14
    Gaitano Boeraeve
    0

    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.

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Dec 21, 2012 @ 11:43
    Lee Kelleher
    100

    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.

  • Gaitano Boeraeve 17 posts 56 karma points
    Dec 21, 2012 @ 11:48
    Gaitano Boeraeve
    0

    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. 

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Dec 21, 2012 @ 11:53
    Lee Kelleher
    0

    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.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies