DynamicNode safe property? (topnavigation in Razor)
Hi!
I'm playing with DynamicModel in Razor and cant figure out how to get a safe property. Here's a rather compact script for a top navigation. In the loop I'd like to add a condition to exclude by umbracoNaviHide's. However that's not so easy to do if I'm not sure all children has that property - since c.umbracoNaviHide will cast an error for nodes without that property. I'm pretty sure this will be addressed in 4.6.2. But I might just as well miss something, and there's a safe get property value available for DynamicNode?
@{ var currentPage = Model; while (currentPage.Level>2) currentPage=Model.Parent; <ul class="topnavigation"> @foreach (var c in currentPage.Children) { <li><a href="@c.Url">@c.Name</a></li> } </ul> }
DynamicNode safe property? (topnavigation in Razor)
Hi!
I'm playing with DynamicModel in Razor and cant figure out how to get a safe property. Here's a rather compact script for a top navigation. In the loop I'd like to add a condition to exclude by umbracoNaviHide's. However that's not so easy to do if I'm not sure all children has that property - since c.umbracoNaviHide will cast an error for nodes without that property. I'm pretty sure this will be addressed in 4.6.2. But I might just as well miss something, and there's a safe get property value available for DynamicNode?
Cheers
Jonas
is working on a reply...