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 am trying to iterate through the contents of a MNTP that is found in a different doctype to the one being modeled. My current code is:
IPublishedContent varSettingsSite = Umbraco.ContentAtRoot().FirstOrDefault(x => x.ContentType.Alias == WtSettingsSite.ModelTypeAlias);
IEnumerable<IPublishedContent> topnavLinks = varSettingsSite.Value("wtSettingsNavTop");
if (topnavLinks != null)
@foreach (var item in topnavLinks)
Unfortunately, I am receiving the "cannot implicitly convert type object to system.collections.generic.ienumerable
If I just make it a var, I cannot loop through it a few lines later.
You need to use below approach to get it converted from object to IEnumerable
var topnavLinks = varSettingsSite.Value<IEnumerable<IPublishedContent>>("wtSettingsNavTop");
I hope that helps you.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted