MNTP - can I use XPath filter to only enable nodes that are selected in another MNTP field somewhere?
This works (hard-coded IDs):
/* [name()='Country' and contains("1780,1779,1788,1588,1638,1724",@id)]
But this doesn't (CSV list of IDs selected on another MNTP):
/* [name()='Country' and contains(//Metadata/Countries/naRegion/text(),@id)]
Is there any way I can use the nodes selected in one MNTP (field called "naRegion" on //Metadata/Countries node, stored as CSV) as the XPath filter on another MNTP field?
I *think* this has to do with context within the XPath itself. When using the "//Metadata/Countries" inside the predicate it would be querying all descendants from the current node, not the root node.
Given that I don't know the structure of your nodes, here's a sledge-hammer approach:
/Country[@isDoc and contains($currentPage/ancestor::root/descendant::Metadata/Countries/naRegion, @id)]
Can't remember which version of uComponents we introduced replacing the "$currentPage" param - I'm sure its been in there a while now.
To explain the rest of the XPath... it will take the currentPage, go up the tree until it reaches the <root>, then back down until it finds all the <Metadata><Countries><naRegion> tags ... then checks if any of them contain the @id value.
Thanks Lee --- I think my problem is the $currentPage thing... this site is running Umbraco v4.7.1, and I think it barfs at the $currentPage parameter.
Just checked - uComponents is v2.2 --- I'm a bit scared of upgrading though, in case it interferes with the datatypes I'm already using on 1,000+ nodes... (eek)
For piece of mind... v2.2 was in such a long beta phase that people thought it was an official release (it never was), so to avoid confusion, we bumped the version number up to v3.0.
The rest of the v3.x.x releases are generally bug fixes (we introduced a new XSLT extension, for CMS Users, hence the bump up to 3.1.x)
As for v4.0 (currently beta), biggest changes are switch from .NET 3.5 to .NET 4.0 (which in turn supports Umbraco 4.6.1+) and change the "nodeFactory" references from "umbraco.presentation.nodeFactory" to the new "umbraco.NodeFactory".
Generally speaking, I've tried to keep backwards-compatiablilty a top priority.
I just upgraded to uComponents 4.0 on Umbraco 4.7.2, and it's my understanding that $currentPage should work in the xpath filter, but I'm having no luck.
Do you know what value the "$currentPage/listingCategory" property has? Is it a string? (Sorry to sound obvious, but I have no idea what the value could be)
MNTP - can I use XPath filter to only enable nodes that are selected in another MNTP field somewhere?
This works (hard-coded IDs):
/* [name()='Country' and contains("1780,1779,1788,1588,1638,1724",@id)]
But this doesn't (CSV list of IDs selected on another MNTP):
/* [name()='Country' and contains(//Metadata/Countries/naRegion/text(),@id)]
Is there any way I can use the nodes selected in one MNTP (field called "naRegion" on //Metadata/Countries node, stored as CSV) as the XPath filter on another MNTP field?
Hi,
I have the same question! Hopefully someone knows the answer soon...
grts,
Kim
Hi Mike,
I *think* this has to do with context within the XPath itself. When using the "//Metadata/Countries" inside the predicate it would be querying all descendants from the current node, not the root node.
Given that I don't know the structure of your nodes, here's a sledge-hammer approach:
Can't remember which version of uComponents we introduced replacing the "$currentPage" param - I'm sure its been in there a while now.
To explain the rest of the XPath... it will take the currentPage, go up the tree until it reaches the <root>, then back down until it finds all the <Metadata><Countries><naRegion> tags ... then checks if any of them contain the @id value.
Good luck!
Cheers, Lee.
Thanks Lee --- I think my problem is the $currentPage thing... this site is running Umbraco v4.7.1, and I think it barfs at the $currentPage parameter.
M
Just checked - uComponents is v2.2 --- I'm a bit scared of upgrading though, in case it interferes with the datatypes I'm already using on 1,000+ nodes... (eek)
Hi Mike,
Just realised that we only added it to uComponents v4.0 (beta) (link to original feature request).
Although it's still a beta, it's very stable - I've been using it on several client projects/websites with no issues - could be worth trying it out?
Cheers, Lee.
Ooooh, that was my original feature request! (Had completely forgotten I'd done that!)
For piece of mind... v2.2 was in such a long beta phase that people thought it was an official release (it never was), so to avoid confusion, we bumped the version number up to v3.0.
The rest of the v3.x.x releases are generally bug fixes (we introduced a new XSLT extension, for CMS Users, hence the bump up to 3.1.x)
As for v4.0 (currently beta), biggest changes are switch from .NET 3.5 to .NET 4.0 (which in turn supports Umbraco 4.6.1+) and change the "nodeFactory" references from "umbraco.presentation.nodeFactory" to the new "umbraco.NodeFactory".
Generally speaking, I've tried to keep backwards-compatiablilty a top priority.
Cheers, Lee.
Just made the mental map between you and your CodePlex username :-)
Hello,
I just upgraded to uComponents 4.0 on Umbraco 4.7.2, and it's my understanding that $currentPage should work in the xpath filter, but I'm having no luck.
My filter looks like this:
/* [contains(categories,$currentPage/listingCategory)]
...where categories is text field with multiple category names, and $currentPage/listingCategory is the category chosen for the current page.
If I just use plain text in the filter, it works perfectly:
/* [contains(categories,"My Great Category Name")]
Should this be working, or am I barking up the proverbial wrong tree?
Hi Andrew,
Do you know what value the "$currentPage/listingCategory" property has? Is it a string? (Sorry to sound obvious, but I have no idea what the value could be)
Thanks, Lee.
Hi Lee, it's a string, as is 'categories'. A typical/hypothetical set of values:
categories="cat1,cat2,cat3"
listingCategory="cat2"
is working on a reply...