Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1474 posts 3431 karma points c-trib
    Oct 11, 2012 @ 12:44
    Simon Dingley
    0

    Checkbox List of Parent MNTP Items

    So here is today's challenge and I thought I put it out to the community first in case there is a component about already that can achieve this.

    I have a site that has a sidebar a Multi-Node Tree Picker property on all nodes to which any number of panels/banners can be added to and which cascade down to child pages. On certain pages the site editors may want to exclude some of the parent sidebar items from displaying on a specified node.

    Normally I would just inherit from parent nodes unless the current node had explicit values set for the side bar and in that situation would replace the entire sidebar however the requirements are slightly more specific in this case.

    My original plan was to use the XPath Checkboxbox datatype to list out parent MNTP selections and allow them to be selected and excluded but I don't think I can *bend* the datatype to output the MNTP Nodes from a parent. 

    Any ideas or alternative approaches to *disconnect* specific parent panels/banners or am I making this more complicated than it needs to be?

    TIA, Simon

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Oct 11, 2012 @ 13:01
    Lee Kelleher
    4

    Hi Simon,

    Challenge accepted.  The XPath CheckBoxList will be able to do this, does require some advanced XPath to make it work though.

    The MNTP will need to use XML for it's data - it's possible that CSV could be used, but the XPath would be much difficult.

    Create an XPath CheckBoxList with the following XPath Expression:

    descendant::*[@isDoc and @id = $ancestorOrSelf/parent::*[@isDoc]/mntp/*/nodeId]

    The "mntp" part would be the property alias of your MNTP field.

    Cheers, Lee.

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Oct 11, 2012 @ 13:12
    Simon Dingley
    0

    Lee you rock! Thanks, I might have to get you to explain that XPath to me or break it down because whilst it works I don't understand why :)

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Oct 11, 2012 @ 13:22
    Lee Kelleher
    4

    Sure thing.  It's straight-forward, once you've got your head around it, (I know, easier said than done!)

    The key part is the inner XPath query:

    $ancestorOrSelf/parent::*[@isDoc]/mntp/*/nodeId

    The "$ancestorOrSelf" parameter is a special case we use within uQuery ... It would try to get the nearest published page to the current page/node (and there I've just found a fault with my original answer ... I'll revise it at the end of this reply)

    It then gets the "nodeId" values from the MNTP.

    The outer XPath query then uses those "nodeId" values:

    descendant::*[@isDoc and @id = "nodeIds"]

    ...

    OK, so I found an issue with my original answer, here's a revised version:

    descendant::*[@isDoc and @id = $ancestorOrSelf/ancestor-or-self::*[@isDoc and mntp/*/nodeId][1]/mntp/*/nodeId]

    This would now work from an unpublished page - previously it would try to locate the parent of the nearest ancestor.

     

    Cheers, Lee.

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Oct 11, 2012 @ 13:26
    Simon Dingley
    0

    Perfect - thanks for the explanation as well as I would never have got to that solution!

Please Sign in or register to post replies

Write your reply to:

Draft