Add IsVisible extension on IPublishedElement

This commit is contained in:
Kenn Jacobsen
2019-03-21 15:01:46 +01:00
parent 77692037f6
commit 33a91bb9e9

View File

@@ -170,5 +170,23 @@ namespace Umbraco.Web
}
#endregion
#region IsSomething
/// <summary>
/// Gets a value indicating whether the content is visible.
/// </summary>
/// <param name="content">The content.</param>
/// <returns>A value indicating whether the content is visible.</returns>
/// <remarks>A content is not visible if it has an umbracoNaviHide property with a value of "1". Otherwise,
/// the content is visible.</remarks>
public static bool IsVisible(this IPublishedElement content)
{
// rely on the property converter - will return default bool value, ie false, if property
// is not defined, or has no value, else will return its value.
return content.Value<bool>(Constants.Conventions.Content.NaviHide) == false;
}
#endregion
}
}