I have a True/False editor in my page doc type and I am using if to create the site navigation.
If topNavigation Checkbox is checked display item in the navigation
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var root = Umbraco.TypedContentAtRoot().First();
var nodes = root.Children.Where(x => x.GetPropertyValue("topNavigation") != "True");
}
<ul class="nav navbar-nav">
@foreach (var page in nodes)
{
<p>@page.GetPropertyValue("topNavigation")</p>
<li class="@(page.IsAncestorOrSelf(Model.Content) ? "current" : null)">
<a href="@page.Url">@page.Name <span class="glyphicon glyphicon-chevron-down"></span></a>
</li>
}
</ul>
@*}*@
I can't seem to compare against a true value.
This shows everything -
var nodes = root.Children.Where(x => x.GetPropertyValue("topNavigation") != "True");
..and this show nothing
var nodes = root.Children.Where(x => x.GetPropertyValue("topNavigation") == "True");
Even though the checkboxes are checked.
You should able to use GetPropertyValue<bool>
var root = Umbraco.TypedContentAtRoot().First();
var nodes = root.Children.Where(x => x.GetPropertyValue<bool>("topNavigation"));