XPath: Get Highest Ancestor of Self Without $currentPage Variable
Hi,
I'm using a DataType I created with Tribal Xpath Node Relations (uComponents) and I also have multiple Root ("Home") nodes because I have multilingual sites. Tricky. I'm creating a dropdown which lists all Resources (hopefully only under the current site/language!) but I'm having an issue where all the Resource items are being listed once for every language/site (because the original site was copied in its entirety). The dropdown is so that a user can select which items to list on the given page.
Obviously, it makes sense that this is happening based on this xpath expression:
//Resource
! I expected this to happen initially. But when I went in to fix it, I realized I needed an expression that would get documents of type Resource under ONLY the highest parent of the current node. I can't figure out how to do this withouth the $currentPage variable, or indeed, without even Having a current context. This is happening in the CMS. I have tried:
Just kind of grabbing at straws here, clearly! Surely someone has come upon this duplicate situation before and can offer me some advice? I do NOT want to do something like this:
//Home[@isDoc and language='English']//Resource
Because then I would need a separate form control for each site specifying the language. That would be a lot of work. And I am a programmer and do not want that ;) Any ideas? Possible in pure xpath?
It's indeed tricky if you don't have *any* context - most of the uComponents "XPath *" pickers allow you to use the variables $currentPage, $parentPage and $ancestorOrSelf (depending on version) to handle these types of situations.
I found this "secret" on a forum post - you can use $currentNodeId in the XPath, so:
#BOOM. Chriztian -- that's another feather in your cap and yet another gift basket I owe you. I had TREID $currentPage although the particular picker I am using does NOT allow it. So THANK YOU!
Both work exactly as I need. Very much appreciated -- and timely :)
XPath: Get Highest Ancestor of Self Without $currentPage Variable
Hi,
I'm using a DataType I created with Tribal Xpath Node Relations (uComponents) and I also have multiple Root ("Home") nodes because I have multilingual sites. Tricky. I'm creating a dropdown which lists all Resources (hopefully only under the current site/language!) but I'm having an issue where all the Resource items are being listed once for every language/site (because the original site was copied in its entirety). The dropdown is so that a user can select which items to list on the given page.
Obviously, it makes sense that this is happening based on this xpath expression:
! I expected this to happen initially. But when I went in to fix it, I realized I needed an expression that would get documents of type Resource under ONLY the highest parent of the current node. I can't figure out how to do this withouth the $currentPage variable, or indeed, without even Having a current context. This is happening in the CMS. I have tried:
Just kind of grabbing at straws here, clearly! Surely someone has come upon this duplicate situation before and can offer me some advice? I do NOT want to do something like this:
Because then I would need a separate form control for each site specifying the language. That would be a lot of work. And I am a programmer and do not want that ;) Any ideas? Possible in pure xpath?
Thanks,
Garrett
Hi Garrett,
It's indeed tricky if you don't have *any* context - most of the uComponents "XPath *" pickers allow you to use the variables $currentPage, $parentPage and $ancestorOrSelf (depending on version) to handle these types of situations.
I found this "secret" on a forum post - you can use $currentNodeId in the XPath, so:
or maybe this will even work:
/Chriztian
THAT'S IT!!!!!
#BOOM. Chriztian -- that's another feather in your cap and yet another gift basket I owe you. I had TREID $currentPage although the particular picker I am using does NOT allow it. So THANK YOU!
Both work exactly as I need. Very much appreciated -- and timely :)
Sincerely,
Garrett
is working on a reply...