x First time here? Check out the FAQ
  • Avatar94posts132karma

    Disallow Current Node Id

    Drew started this topic 3 months ago , this topic was edited at: Tuesday, February 21, 2012 11:29 AM, Go directly to the topic solution

    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

     


  • Replies

  • Avatar94posts132karma
    Comment with ID: 108572
    Drew posted this reply 3 months ago

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


  • Avatar457posts1443karma
    Comment with ID: 108573
    Hendy Racher posted this reply 3 months ago

    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 posted this reply 3 months ago

    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.


  • Avatar457posts1443karma
    Comment with ID: 108577
    Hendy Racher posted this reply 3 months ago

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


  • Lee Kelleher posted this reply 3 months ago

    @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.


  • Avatar457posts1443karma
    Comment with ID: 108581
    Hendy Racher posted this reply 3 months ago

    @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 :)


  • Avatar457posts1443karma
    Comment with ID: 108582
    Hendy Racher posted this reply 3 months ago

    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)


  • Avatar94posts132karma
    Comment with ID: 108648
    Drew posted this reply 3 months ago

    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 posted this reply 3 months ago

    @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 login or Sign up To post replies