Copied to clipboard

Flag this post as spam?

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


  • Trevor Loader 199 posts 256 karma points
    Jan 02, 2012 @ 00:33
    Trevor Loader
    0

    How to use XPath key?

    Hey Morten,

    Firstly...great package! I've used it in many sites and love it.

    However, in the latest site I'm creating, I want to have standard values being pulled from a parent content node...which I assume you can do by creating a XPath key.  But I can't figure out how to reference the 'parent' as there is no current page.

    Note that I can't use the Node key type to hard code the parent as the parent node may be different.  Ie, my content tree looks like Companies > Company > Branch and I'm trying to make the Branch standard values pull from the Company node.

    Is it possible?  If so, can you please supply a sample XPath snippet for getting a property value from the parent?

    TIA, Trevor.

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Jan 02, 2012 @ 21:17
    Morten Christensen
    1

    Hi Trevor,

    I'm afraid that the XPath can only be used for somewhat static values, as you have to start from the root with something like:
    /root/node[@id='1048']/data
    Behind the scenes it's simple using "umbracoXml.SelectSingleNode(xpath).InnerText".

    I have been thinking about adding some more flexibility with regards to getting values from parents and ancestors, as the current methods aren't as dynamic as I would have liked. But I never got around to it. But it should be a fairly simple task to implement.
    I will try to implement 'parent' and 'ancestor' as new types, so you simple need to create a new key and specify the property alias that contains the value you want to insert.

    I'll post back when its ready.

    - Morten

  • Trevor Loader 199 posts 256 karma points
    Jan 02, 2012 @ 21:47
    Trevor Loader
    0

    That would be awesome.

    Thanks, Trevor

  • Dan White 206 posts 510 karma points c-trib
    Mar 05, 2013 @ 04:49
    Dan White
    0

    @Morten, with that added functionality would you be able to traverse up the tree until you hit a parent node of specified doctype (like currentPage)?

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Mar 10, 2013 @ 17:43
    Morten Christensen
    0

    Hi Dan,

    Sorry for the late reply.

    This functionality is still limited to inputting an XPath, which will be applied to the published content xml cache, but it still has no context of currentpage. So it won't be able to traverse up and down like you are used to in xslt.
    I could probably add the Id of the current page by replacing a pre-defined key, but not sure if this will be sufficient for what you want to do ?

    - Morten

  • umbracocool 108 posts 197 karma points
    May 28, 2013 @ 10:17
    umbracocool
    0

    Hello friends!. Found a solution to use XPath? and thus be able to traverse the nodes above and below the current one.

    There is a documentation for the use of standard values?. Sorry friends is that I am new to this. Great package!, Many Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft