Wonderful - keep it coming. As for the scenarios, I should have been more clear. By ContentRoot, I didn't meant the "Root" but the "Site" ie. Node 1 or Node 3.
For query 2, assuming that I was somewhere deep in the "node 1" part of the structure, I'd want to find Node 2 (or "first occurrence in the site of something with a doctype B).
If I wanted to find the first occurance of Node type D Assuming that the first occurrence in this instance means working down each tree branch until the first occurrence is found then I'd do the following:
//First check the current branch
var currentBranch = Umbraco.Content(Model.Path.Split(","));
var firstNodeOfTypeD = currentBranch.FirstOrDefault(n=>n.ContentType.Alias.Equals("d"));
if(firstNodeOfTypeD == null)
{
firstNodeOfTypeD = Model.Site().DescendantOfType("d");
}
However that implies the first occurrence means working down each branch.
Another interpretation of this request could mean you need to return Page 2, because that is the "first occurrence of type D" when level is a higher priority.
In this scenario,
var firstOccuranceOfTypeD = Model.Site().DescendantsOfType("d").OrderBy(n=>n.Level).ThenBy(n=>n.SortOrder).FirstOrDefault();
How do you prefer to query data in Umbraco 8?
Given a medium sized site (2.000-5.000 content nodes), I need the most efficient way to find the published versions of
How would you solve those two? Ie. how would your query in your view look like?
Best,
Niels...
For part 1, I'd look to use Examine to find all the nodes of a specific type.
So something like:
But this is on the assumption that by ContentRoot you mean the very root of the entire content section.
With regards to query 2, what do you mean by first occurrence? In this example is Node 2 or Node 3 the first occurrence?
Thanks
Nik
Wonderful - keep it coming. As for the scenarios, I should have been more clear. By ContentRoot, I didn't meant the "Root" but the "Site" ie. Node 1 or Node 3.
For query 2, assuming that I was somewhere deep in the "node 1" part of the structure, I'd want to find Node 2 (or "first occurrence in the site of something with a doctype B).
Okay, so if I had a site structure as follows:
And say I was on Page 1.1.1.1
Then,
If I wanted to find the first occurance of Node type D Assuming that the first occurrence in this instance means working down each tree branch until the first occurrence is found then I'd do the following:
However that implies the first occurrence means working down each branch.
Another interpretation of this request could mean you need to return Page 2, because that is the "first occurrence of type D" when level is a higher priority.
In this scenario,
This version could also be done in examine.
How about:
Cheers
Paul
I feel like mine would be slow in v7 but i'm led to believe it is quicker v8 this way
is working on a reply...