I'm trying to display the latest new article on my home page using Umbraco 5.0.
The parent new item is passed as a macro parameter called "news" and I successfully get the node by:
string newsFolderId = Model.MacroParameters.news; var newsFolderHiveId = new Umbraco.Framework.HiveId(newsFolderId); var newsItemParent = Hive.Content.Where(content => content.Id == newsFolderHiveId).FirstOrDefault(); var newsItem = newsItemParent.ChildContent().FirstOrDefault();
Looking at newsItem.Name etc, I've got the node I want, but when I try to access the fields I the error "Sorry, an error occurred while processing your request."
For example, I've tried the following to get bodyText field which contains the main HTML of the article
Umb 5 - Display Latest News
I'm trying to display the latest new article on my home page using Umbraco 5.0.
The parent new item is passed as a macro parameter called "news" and I successfully get the node by:
Looking at newsItem.Name etc, I've got the node I want, but when I try to access the fields I the error "Sorry, an error occurred while processing your request."
For example, I've tried the following to get bodyText field which contains the main HTML of the article
What am I missing??
Thanks,
Fran
I think you should to make sure by checking number of ChildContent should have at least 1 node and let try get bodyText "asDynamic" like this:
if(newsItemParent.ChildContent().Count() > 1)
{
newsItem.AsDynamic().bodyText;
}
Please let me know if it work :)
That did it!
Thank you
is working on a reply...