How to select nodes in a different branch of the document tree
Hello,
I've got a document tree with two branches, one for people and one for projects.
Projects are associated with people, but are not subordinate to them. When I display a people page, I want also to show all of that person's associated projects. I tried using
and then filter that list for people, but the list comes back empty. I think it is because the query is being executed in the context of currentPage which does not contain projects.
How do I get a list of nodes in a different branch of the document tree?
The above would collect all project nodes in the variable - it's inefficient because of the double slash (descendant::) axis, but should let you confirm they're there.
Hi there. Im trying to get an usercontrol (.net) c# to iterate thru total content tree and find me a page that have the property (alias=MyDistinctPage, value=1stUserHomePage) There ar ONLY one page in content tree that matches this alias/value.
My suggestion:
XPathNodeIterator it = umbraco.library.GetXmlNodeByXPath("//node[(./data[@alias='MyDistinctPage' and text()='1stUserHomePage'])]"); Sad to say, I get noting back, nada, zip.
How to select nodes in a different branch of the document tree
Hello,
I've got a document tree with two branches, one for people and one for projects.
Projects are associated with people, but are not subordinate to them. When I display a people page, I want also to show all of that person's associated projects. I tried using
umbraco.library:GetXmlNodeByXPath('/root/node[@nodeTypeAlias="project"]')
and then filter that list for people, but the list comes back empty. I think it is because the query is being executed in the context of currentPage which does not contain projects.
How do I get a list of nodes in a different branch of the document tree?
Thanks, Jon
Hi Jon,
If "people" and "projects" are in the Umbraco Content tree (and published) they should be available through an XPath from $currentPage, e.g.:
The above would collect all project nodes in the variable - it's inefficient because of the double slash (descendant::) axis, but should let you confirm they're there.
/Chriztian
Thanks, that solved it.
Hi there.
Im trying to get an usercontrol (.net) c# to iterate thru total content tree and find me a page that have the property (alias=MyDistinctPage, value=1stUserHomePage)
There ar ONLY one page in content tree that matches this alias/value.
My suggestion:
XPathNodeIterator it = umbraco.library.GetXmlNodeByXPath("//node[(./data[@alias='MyDistinctPage' and text()='1stUserHomePage'])]");
Sad to say, I get noting back, nada, zip.
Any...ideas? :)
Dropped it.
After several tries, I just went:
foreach
(umbraco.cms.businesslogic.web.Document pages in Document.GetDocumentsOfDocumentType(myDocTypeID))
Then i if'ed pages.getProperty("PropIWantet").value.
Taataa
is working on a reply...