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
Converting a previously working menu to strongly typed in V7.2.2
var home = Model.Content.AncestorOrSelf(); var pageCollection = home.Children;
var topPages = pageCollection.Where(x => x.IsVisible() && x.GetPropertyValue<bool>("showInTopMenu"));
@foreach (var page in topPages) { <------Fails, says previous line is NullReferenceException
I suspect I can't just "foreach" through it, but can't find reliable info :(
If I put topPages out to the page I get
System.Linq.Enumerable+WhereEnumerableIterator`1[Umbraco.Core.Models.IPublishedContent]
Any clues or links appreciated.
Craig
Yes, you can as its a enumerable. I'm assuming you expect topPages to not be empty?
Could post the whole code and the whole error?
Jeavon
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Iterating through an IPublishedContent collection
Converting a previously working menu to strongly typed in V7.2.2
var home = Model.Content.AncestorOrSelf();
var pageCollection = home.Children;
var topPages = pageCollection.Where(x => x.IsVisible() && x.GetPropertyValue<bool>("showInTopMenu"));
@foreach (var page in topPages) { <------Fails, says previous line is NullReferenceException
I suspect I can't just "foreach" through it, but can't find reliable info :(
If I put topPages out to the page I get
System.Linq.Enumerable+WhereEnumerableIterator`1[Umbraco.Core.Models.IPublishedContent]
Any clues or links appreciated.
Craig
Yes, you can as its a enumerable. I'm assuming you expect topPages to not be empty?
Could post the whole code and the whole error?
Jeavon
is working on a reply...