Copied to clipboard

Flag this post as spam?

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


  • Drew 165 posts 340 karma points
    Feb 20, 2012 @ 16:11
    Drew
    0

    Disallow Current Node Id

    I've got a CaseStudy doctype, it has the option to choose related case studies (multinodetreepicker).

    I'd like to stop the user from selecting the current node, so I've got my XPath Filter set up:

    /*[name()='CaseStudy' and @id != $currentPage/@id]

    It doesn't like the use of $currentPage/@id

    If I do something with a hardcoded value, such as:

    @id != '1113'
    it works fine.

     

    Any suggestions? I've tried a few things with no luck.
    (I should really know this...too)

     

    Cheers,

    Drew

     

  • Drew 165 posts 340 karma points
    Feb 20, 2012 @ 16:12
    Drew
    0

    Oh and Xpath type is set to 'current' and not 'global' :)

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 20, 2012 @ 16:22
    Hendy Racher
    0

    Hi Drew,

    I've not tested this, but does it work if you change the setting to 'Global' and use the following XPath expression:

    /*[name() = 'CaseStudy' and @id != $currentPage]

    HTH,

    Hendy

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 20, 2012 @ 16:28
    Lee Kelleher
    1

    Unfortunately, the XPath expression for filters isn't parsed using uQuery (which handles the $currentPage replacement) ... so not sure that you can do what you need.

    We'll look at what is involved in making this work for a future release.

    Cheers, Lee.

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 20, 2012 @ 16:32
    Hendy Racher
    0

    Arrh, I missed the bit about it being a filter expression - oops

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 20, 2012 @ 16:39
    Lee Kelleher
    0

    @Hendy: How's about this for a solution: In 'XmlTreeNodeExtensions.cs', the 'DetermineClickable' method the XPath expression is passed to an XElement extension method called 'XPathSelectElements' ... before this happens, we could handle the $currentPage (and other known params) in the XPath expression (string).

    Very similar to what we do in 'uQuery.GetNodesByXPath', but we don't query the nodes, just handle/parse/replace the params in the XPath?

    Cheers, Lee.

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 20, 2012 @ 16:53
    Hendy Racher
    0

    @Lee, yes, we could do the string replacement in the OnRenderNode event in FilteredContentTree.cs (wouldn't need to apply to the media tree) - It does mean the string replacement would occur for each node being rendered, but much easier to apply :)

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 20, 2012 @ 16:57
    Hendy Racher
    1

    Infact how about just checking for the existance of "$currentPage" in the string, if present, update the XPath and store in the cookie ? (I'm assuming it's easy to get hold of the current page id)

  • Drew 165 posts 340 karma points
    Feb 21, 2012 @ 10:45
    Drew
    0

    Thanks for the response guys!

    Disallowing selection of the current node in MTP was a nice to have - it's not critical to the picker - but when I've got a minute I'll see about making the relevant changes (unless someone beats me to it!).

     

    Cheers!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 21, 2012 @ 11:29
    Lee Kelleher
    0

    @Hendy, Curious how the storing it in a cookie would work? The XPath would need $currentPage to be variable across pages right?

    @Drew, I've started to write some code for this... haven't got too far with it yet though (e.g. not pushed anything back to the repo).

    Cheers, Lee.

Please Sign in or register to post replies

Write your reply to:

Draft