Class FriendlyPublishedElementExtensions
- Namespace
- Umbraco.Extensions
- Assembly
- Umbraco.Web.Common.dll
public static class FriendlyPublishedElementExtensions
- Inheritance
-
FriendlyPublishedElementExtensions
- Inherited Members
Methods
IsVisible(IPublishedElement)
Gets a value indicating whether the content is visible.
public static bool IsVisible(this IPublishedElement content)
Parameters
content
IPublishedElementThe content.
Returns
- bool
A value indicating whether the content is visible.
Remarks
A content is not visible if it has an umbracoNaviHide property with a value of "1". Otherwise, the content is visible.
Value(IPublishedElement, string, string?, string?, Fallback?, object?)
Gets the value of a content's property identified by its alias.
public static object? Value(this IPublishedElement content, string alias, string? culture = null, string? segment = null, Fallback? fallback = null, object? defaultValue = null)
Parameters
content
IPublishedElementThe content.
alias
stringThe property alias.
culture
stringThe variation language.
segment
stringThe variation segment.
fallback
FallbackOptional fallback strategy.
defaultValue
objectThe default value.
Returns
- object
The value of the content's property identified by the alias, if it exists, otherwise a default value.
Remarks
The value comes from IPublishedProperty
field Value
ie it is suitable for use when rendering
content.
If no property with the specified alias exists, or if the property has no value, returns
defaultValue
.
If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter.
The alias is case-insensitive.
ValueFor<TModel, TValue>(TModel, Expression<Func<TModel, TValue>>, string?, string?, Fallback?, TValue?)
Gets the value of a property.
public static TValue? ValueFor<TModel, TValue>(this TModel model, Expression<Func<TModel, TValue>> property, string? culture = null, string? segment = null, Fallback? fallback = null, TValue? defaultValue = default) where TModel : IPublishedElement
Parameters
model
TModelproperty
Expression<Func<TModel, TValue>>culture
stringsegment
stringfallback
FallbackdefaultValue
TValue
Returns
- TValue
Type Parameters
TModel
TValue
Value<T>(IPublishedElement, string, string?, string?, Fallback?, T?)
Gets the value of a content's property identified by its alias, converted to a specified type.
public static T? Value<T>(this IPublishedElement content, string alias, string? culture = null, string? segment = null, Fallback? fallback = null, T? defaultValue = default)
Parameters
content
IPublishedElementThe content.
alias
stringThe property alias.
culture
stringThe variation language.
segment
stringThe variation segment.
fallback
FallbackOptional fallback strategy.
defaultValue
TThe default value.
Returns
- T
The value of the content's property identified by the alias, converted to the specified type.
Type Parameters
T
The target property type.
Remarks
The value comes from IPublishedProperty
field Value
ie it is suitable for use when rendering
content.
If no property with the specified alias exists, or if the property has no value, or if it could not be
converted, returns default(T)
.
If eg a numeric property wants to default to 0 when value source is empty, this has to be done in the converter.
The alias is case-insensitive.