Table of Contents

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 IPublishedElement

The 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 IPublishedElement

The content.

alias string

The property alias.

culture string

The variation language.

segment string

The variation segment.

fallback Fallback

Optional fallback strategy.

defaultValue object

The 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 TModel
property Expression<Func<TModel, TValue>>
culture string
segment string
fallback Fallback
defaultValue 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 IPublishedElement

The content.

alias string

The property alias.

culture string

The variation language.

segment string

The variation segment.

fallback Fallback

Optional fallback strategy.

defaultValue T

The 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.