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:
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?
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?)
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...
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.
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.
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..)
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.
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.
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.
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
So, I guess you're in the usercontrol's .net code when excuting the xpath?
Roland,
I'm not following you here... what exactly do you mean?
Cheers,
/Dirk
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 :)
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
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
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
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
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
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
is working on a reply...