Are you doing this on the front or back end of the site? If you're in the front end, DON'T use the ContentService, as it hits the database, use the ContentCache instead, which will allow you to do the type of query that you're after!
Can you give me a bit of information about where in your application you're trying to query the nodes (front end or back office etc), and I'll see if I can give you some example code!
How to get a node by name n levels down in v6.0.2?
If I use
ApplicationContext.Current.Services.ContentService.GetChildrenByName(NodeId, "NodeName");
It can only find nodes directly under NodeId.
What options have I got for finding nodes by name in the tree at any level under NodeId?
Hi Rob,
Are you doing this on the front or back end of the site? If you're in the front end, DON'T use the ContentService, as it hits the database, use the ContentCache instead, which will allow you to do the type of query that you're after!
Can you give me a bit of information about where in your application you're trying to query the nodes (front end or back office etc), and I'll see if I can give you some example code!
I am using it on the front end, example code would be welcome.
I'll assume you're using a Razor Macro or MVC view, in which case, something like this should do the trick for you:
Will get you all of the descendants of the node with the id you pass in with the document type alias that you pass in to the Descendants function.
If you want to get the nodes by the actual text name of the nodes, you could try:
There's some documentation on querying content on the front end here:
https://github.com/umbraco/Umbraco4Docs/blob/master/Documentation/Reference/Templating/Mvc/querying.md
Hope that helps!
:)
is working on a reply...