Search Results for

    Show / Hide Table of Contents
    View Source

    Class FriendlyPublishedElementExtensions

    Inheritance
    object
    Namespace: Umbraco.Extensions
    Assembly: Umbraco.Web.Common.dll
    Syntax
    public static class FriendlyPublishedElementExtensions

    Methods

    View Source

    IsVisible(IPublishedElement)

    Gets a value indicating whether the content is visible.

    Declaration
    public static bool IsVisible(this IPublishedElement content)
    Parameters
    Type Name Description
    IPublishedElement content

    The content.

    Returns
    Type Description
    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.

    View Source

    Value(IPublishedElement, string, string?, string?, Fallback, object?)

    Gets the value of a content's property identified by its alias.

    Declaration
    public static object? Value(this IPublishedElement content, string alias, string? culture = null, string? segment = null, Fallback fallback = default, object? defaultValue = null)
    Parameters
    Type Name Description
    IPublishedElement content

    The content.

    string alias

    The property alias.

    string culture

    The variation language.

    string segment

    The variation segment.

    Fallback fallback

    Optional fallback strategy.

    object defaultValue

    The default value.

    Returns
    Type Description
    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.

    View Source

    ValueFor<TModel, TValue>(TModel, Expression<Func<TModel, TValue>>, string?, string?, Fallback, TValue?)

    Gets the value of a property.

    Declaration
    public static TValue? ValueFor<TModel, TValue>(this TModel model, Expression<Func<TModel, TValue>> property, string? culture = null, string? segment = null, Fallback fallback = default, TValue? defaultValue = default) where TModel : IPublishedElement
    Parameters
    Type Name Description
    TModel model
    Expression<Func<TModel, TValue>> property
    string culture
    string segment
    Fallback fallback
    TValue defaultValue
    Returns
    Type Description
    TValue
    Type Parameters
    Name Description
    TModel
    TValue
    View Source

    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.

    Declaration
    public static T? Value<T>(this IPublishedElement content, string alias, string? culture = null, string? segment = null, Fallback fallback = default, T? defaultValue = default)
    Parameters
    Type Name Description
    IPublishedElement content

    The content.

    string alias

    The property alias.

    string culture

    The variation language.

    string segment

    The variation segment.

    Fallback fallback

    Optional fallback strategy.

    T defaultValue

    The default value.

    Returns
    Type Description
    T

    The value of the content's property identified by the alias, converted to the specified type.

    Type Parameters
    Name Description
    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.

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX