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
I'm working on a site that has some "settings" nodes (specific document types) located below the home node along with my content nodes I do wish to be visible (faq, gallery etc.). The nodes to ignore could for example be a node for email sent successfully, sitemap and custom error pages.
It could look something like this:
To my knowledge I can't easily ignore such nodes without manually filtering everywhere I query the content tree. An example could be in a partial view rendering siblings or children in a sidebar, or content or seo sitemaps that traverses the content tree. It is also not possible to move these nodes "outside" the home node, as they are rendered within the master template and thus depending on its properties.
Nodes and their properties can of course be ignored in the examine index, but this still doesn't solve the above problem.
No matter what I think of, it is very inefficient and time consuming keeping everything synchronized.
If you have the golden answer to this problem, then please fill me in :)
This might not be exacly what you where looking for, but could you maybe use the umbracoNaviHide property on these document types, and in your views only use .Where("Visible")?
That way you don't need to filter away documentTypes by their alias in every view (which I agree is not nice) and I know most sitemap packages for Umbraco take this property in consideration so you won't get these pages in the sitemap either.
Then if you for some reason need to access these property in your views, you can just skip the where clause.
I also think from Umbraco 7.4 (not sure) you can set default values on most properties, that way you can set this property to default=true and avoid having to tick that box every time.
Best of luck!!!
Thank you for your reply.
I have for some time ago seen a true/false editor with the ability to set a default state. Just cant remember the name of it...
I am already using the umbracoNaviHide property along with .Where(x => x.IsVisible()) along with other expressions. However, when iterating over a collection of IPublishedContent nodes in a foreach and for example checking a node IsLast(), the method will never return true, as the collection has been filtered. Correct me if I am wrong.
The best case would be to set the umbracoNaviHide property of the document type while preventing users with access to change the value. Please remember that I never want the node to be visible in menus, sitemaps, lists etc.
Funny that this is not added to the core, as I find myself having the exact same problem for each site I am creating - unfortunately this site does not make it possible to use the usual "hacks" :(
Looks like you're right! And I found no way (well, I looked for about a minute) to make the built-in IsFirst and IsLast work with the Visible filtering.
In order for you to move on, create the following class (you could just drop it into ~/App_Code:
// From: http://stackoverflow.com/a/14687229/5018
public static class IEnumerableExtensions
public static bool IsLast<T>(this IEnumerable<T> items, T item)
var last = items.LastOrDefault();
if (last == null)
public static bool IsFirst<T>(this IEnumerable<T> items, T item)
var first = items.FirstOrDefault();
if (first == null)
public static bool IsFirstOrLast<T>(this IEnumerable<T> items, T item)
return items.IsFirst(item) || items.IsLast(item);
And then you can figure out if it's the last item like a little so:
var home = Model.Content.AncestorOrSelf(1);
var pages = home.Children.Where(x => x.IsVisible());
@foreach (var childPage in pages)
Hi Sebastiaan, and thank you for your reply. I'm sorry that I have left you hanging, but I forgot all about your answer.
I didn't think of creating an extension as you suggested, but it works like a charm! It would of course be nice if any type of filtering would work with collections of IPublishedContent, but for now I'll manage :)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted