Search Results for

    Show / Hide Table of Contents
    View Source

    Interface IUrlSegmentProvider

    Provides URL segments for content.

    Namespace: Umbraco.Cms.Core.Strings
    Assembly: Umbraco.Core.dll
    Syntax
    public interface IUrlSegmentProvider
    Remarks

    Url segments should comply with IETF RFCs regarding content, encoding, etc.

    Properties

    View Source

    AllowAdditionalSegments

    Gets a value indicating whether the URL segment provider allows additional segments after providing one.

    Declaration
    bool AllowAdditionalSegments { get; }
    Property Value
    Type Description
    bool
    Remarks

    If set to true, when more than one URL segment provider is available, futher providers after this one in the collection will be called even if the current provider provides a segment. If false, the provider will terminate the chain of URL segment providers if it provides a segment.

    Methods

    View Source

    GetUrlSegment(IContentBase, bool, string?)

    Gets the URL segment for a specified content, published status and culture.

    Declaration
    string? GetUrlSegment(IContentBase content, bool published, string? culture = null)
    Parameters
    Type Name Description
    IContentBase content

    The content.

    bool published

    Whether to get the published URL segment.

    string culture

    The culture.

    Returns
    Type Description
    string

    The URL segment.

    Remarks

    This is for when Umbraco is capable of managing more than one URL per content, in 1-to-1 multilingual configurations. Then there would be one URL per culture.

    View Source

    GetUrlSegment(IContentBase, string?)

    Gets the URL segment for a specified content and culture.

    Declaration
    string? GetUrlSegment(IContentBase content, string? culture = null)
    Parameters
    Type Name Description
    IContentBase content

    The content.

    string culture

    The culture.

    Returns
    Type Description
    string

    The URL segment.

    Remarks

    This is for when Umbraco is capable of managing more than one URL per content, in 1-to-1 multilingual configurations. Then there would be one URL per culture.

    View Source

    HasUrlSegmentChanged(IContentBase, string?, string?)

    Determines whether the URL segment for the given content has changed compared to the currently published segment. Used by redirect tracking to avoid unnecessary descendant traversal when URL segments haven't changed.

    Declaration
    bool HasUrlSegmentChanged(IContentBase content, string? currentPublishedSegment, string? culture)
    Parameters
    Type Name Description
    IContentBase content

    The content being published (carries new property values).

    string currentPublishedSegment

    The currently published URL segment (from IDocumentUrlService).

    string culture

    The culture.

    Returns
    Type Description
    bool

    True if the segment has changed, false otherwise.

    Remarks

    The default implementation computes the new URL segment via GetUrlSegment(IContentBase, bool, string?) using draft values (published: false) and compares it to currentPublishedSegment. Draft values are used because this method is called during publishing, before the new values are committed as published — so the draft values represent what the segment will be after publishing. This is intentionally a permanent default so that custom providers automatically get correct change detection without additional implementation. Override only if you need custom change detection logic (e.g., URL segments derived from external state).

    View Source

    MayAffectDescendantSegments(IContentBase)

    Determines whether changes to the given content item may affect URL segments of its descendant content items. Used by redirect tracking to decide whether descendant traversal can be skipped when the content item's own URL segment is unchanged.

    Declaration
    bool MayAffectDescendantSegments(IContentBase content)
    Parameters
    Type Name Description
    IContentBase content

    The content item being published.

    Returns
    Type Description
    bool

    true if this provider may compute descendant segments based on data from this content item; false if this provider only uses each content item's own data.

    Remarks

    The default is false, meaning this provider derives segments solely from the content item itself (e.g. its Name or properties). Custom providers that read ancestor properties to compute descendant segments should override this — either returning true unconditionally, or using logic (e.g. checking the content type or whether relevant properties have changed) to limit the impact to affected subtrees.

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