Copied to clipboard

Flag this post as spam?

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


  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 04, 2011 @ 10:09
    Dirk De Grave
    0

    How to set the XPath Expression (from Current) in case current node not yet published

    Hi guys,

    Just asking some advice on whether the following is possible:

    I've got a doc type A with a property of type Multi-Node Tree Picker (to pick nodes of doc type B).

    As I've got a multilanguage site (fr/nl having the same content structure), I'd like to select all nodes of doc type B in the current "language" tree node, so xpath is built up like so:

    ancestor-or-self::*[@isDoc][@level=2]//descendant::*[@isDoc][name() = 'ProductCatalogContainer']

    to select the starting node. This works great if the current node I'm editing is published... but doesn't work when it's not giving me a [No start node found] message. 

    Yes, I've read the instruction on how to set up the XPath expression which says that only published nodes can be shown, so I know what I doing "wrong".

    Funnily enough, I can select doc type B documents which are not yet published from the multi node tree picker...

    I don't want to revert to using the 'Node Picker' as node seletion type as this would mean I've got to set the starting node to a (grand)parent node, making it possible for the user to select nodes from another "language". It also means the user has to click more to get to the node to select.

    Any ideas if there's a way to only select nodes from the current "language" tree the user's in?

     

    TIA,

    /Dirk

  • RolandWolters 42 posts 63 karma points
    May 04, 2011 @ 10:15
    RolandWolters
    0

    So, I guess you're in the usercontrol's .net code when excuting the xpath?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 04, 2011 @ 10:18
    Dirk De Grave
    0

    Roland,

    I'm not following you here... what exactly do you mean?

     

    Cheers,

    /Dirk

  • RolandWolters 42 posts 63 karma points
    May 04, 2011 @ 10:39
    RolandWolters
    0

    I was wondering if this was xslt code or inside some .net component. Because you are in an unpublished node, like you said you cannot xpath because the node is not in the xml output yet. But you can get the current node's id, get the node (well err the document of course) and traverse up to the parent. So my idea was to get the parent's node id, and base the xpath on getnodebyid (will that work in xpath?)

    Hey it's just an idea  :)

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 04, 2011 @ 10:44
    Dirk De Grave
    0

    Roland,

    no xslt code, no .net component, i'm using the standard datatype multi-node tree picker from uComponents, so don't think your solution would work in my scenario...

     

    Cheers,

    /Dirk

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    May 04, 2011 @ 10:50
    Hendy Racher
    5

    Hi Dirk,

    Yes it's possible to only select nodes from the current language by walking up the tree from the current node, and it's also possible to do so when the current node with the MNTP is unpublished.

    To configure the MNTP, set:

    Node selection type = XPath Expression

    XPath type = Global

    XPath expression = $ancestorOrSelf/ancestor-or-self::*[@isDoc][@level=2]//descendant::*[@isDoc][name() = 'ProductCatalogContainer']

    Setting the XPath type to global causes the MNTP to evaluate the start node via uQuery.GetNodesByXPath, which in turn will parse for "$ancestorOrSelf" to find the nearest published node.

    HTH,

    Hendy

  • Lennart Stoop 304 posts 842 karma points
    May 04, 2011 @ 10:53
    Lennart Stoop
    0

    Hey Dirk,

    I don't think there's a way to get this relative xpath xpression working when the node hasn't been published.

    Perhaps there you could set up your document types in such a way that publishing it first does not have to be an issue (seperate doc type without a template?)

    Not sure if this is the UX you were hoping for though (users would still have to publish first..)

     

    Grtz

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 04, 2011 @ 11:23
    Dirk De Grave
    0

    Hi Hendy,

    you're my new uComponents hero! i'm currently working on changeset 74901 which fixes an issue with the quote character when using the multitextstring datatype, but that version doesn't have the $ancestorOrSelf param (instead of the $parentPage param)

    *downloading changeset 75135 now*

    @Lennart, it IS possible, you only need to follow Hendy's guidelines on setting up the params for the datatype.

     

    Cheers,

    /Dirk

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    May 04, 2011 @ 11:32
    Hendy Racher
    0

    Hi Dirk,

    Ahhh I wasn't sure if $ancestorOrSelf was in last release, $currentPage and $parentPage are I think, but it's tempting to also remove $currentPage as $ancestorOrSelf covers all the schenarios.

    Cheers,

    Hendy

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 04, 2011 @ 11:47
    Dirk De Grave
    0

    Yup, $currentPage and $parentPage were available, just downloaded the changeset with $ancestorOrSelf, build the project and copied the dll's to the bin folder. All is well now!!

    Big thanks again for pointing me to the right solution.

     

    Cheers,

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft