Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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?
For part 1, I'd look to use Examine to find all the nodes of a specific type.
So something like:
var query = searcher.CreateQuery().NodeTypeAlias(MyContentType.ModelTypeAlias);
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?
> Node 1 (doc type A)
> Node 2 (doc type B)
> Node 3 (doc type B)
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:
> site root
> Page 1 (A)
> Page 1.1 (B)
> Page 1.1.1 (D)
> Page 184.108.40.206 (E)
> Page 1.2 (B)
> Page 1.3 (C)
> Page 1.4 (D)
> Page 2 (D)
> Page 2.1 (B)
> Page 2.2 (C)
> Page 2.3 (D)
And say I was on Page 220.127.116.11
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();
This version could also be done in examine.
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...
Write your reply to:
Image will be uploaded when post is submitted