Class FriendlyPublishedContentExtensions
- Namespace
 - Umbraco.Extensions
 
- Assembly
 - Umbraco.Web.Common.dll
 
public static class FriendlyPublishedContentExtensions
  - Inheritance
 - 
      
      FriendlyPublishedContentExtensions
 
- Inherited Members
 
Methods
Children(IPublishedContent, Func<IPublishedContent, bool>, string?)
Gets the children of the content, filtered by a predicate.
public static IEnumerable<IPublishedContent>? Children(this IPublishedContent content, Func<IPublishedContent, bool> predicate, string? culture = null)
  Parameters
contentIPublishedContentThe content.
predicateFunc<IPublishedContent, bool>The predicate.
culturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- IEnumerable<IPublishedContent>
 The children of the content, filtered by the predicate.
Remarks
Children are sorted by their sortOrder.
Children(IPublishedContent, string?)
Gets the children of the content item.
public static IEnumerable<IPublishedContent> Children(this IPublishedContent content, string? culture = null)
  Parameters
contentIPublishedContentThe content item.
culturestringThe specific culture to get the URL children for. Default is null which will use the current culture in Umbraco.Cms.Core.Models.PublishedContent.VariationContext
Returns
- IEnumerable<IPublishedContent>
 
Remarks
Gets children that are available for the specified culture.
Children are sorted by their sortOrder.
For culture, if null is used the current culture is used. If an empty string is used only invariant children are returned. If "*" is used all children are returned.
If a variant culture is specified or there is a current culture in the Umbraco.Cms.Core.Models.PublishedContent.VariationContext then the Children returned will include both the variant children matching the culture AND the invariant children because the invariant children flow with the current culture. However, if an empty string is specified only invariant children are returned.
ChildrenAsTable(IPublishedContent, string, string?)
Gets the children of the content in a DataTable.
public static DataTable ChildrenAsTable(this IPublishedContent content, string contentTypeAliasFilter = "", string? culture = null)
  Parameters
contentIPublishedContentThe content.
contentTypeAliasFilterstringAn optional content type alias.
culturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- DataTable
 The children of the content.
ChildrenOfType(IPublishedContent, string, string?)
Gets the children of the content, of any of the specified types.
public static IEnumerable<IPublishedContent>? ChildrenOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
  Parameters
contentIPublishedContentThe content.
contentTypeAliasstringThe content type alias.
culturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- IEnumerable<IPublishedContent>
 The children of the content, of any of the specified types.
Children<T>(IPublishedContent, string?)
Gets the children of the content, of a given content type.
public static IEnumerable<T>? Children<T>(this IPublishedContent content, string? culture = null) where T : class, IPublishedContent
  Parameters
contentIPublishedContentThe content.
culturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- IEnumerable<T>
 The children of content, of the given content type.
Type Parameters
TThe content type.
Remarks
Children are sorted by their sortOrder.
CreateModel(IPublishedContent)
Creates a strongly typed published content model for an internal published content.
public static IPublishedContent? CreateModel(this IPublishedContent content)
  Parameters
contentIPublishedContentThe internal published content.
Returns
- IPublishedContent
 The strongly typed published content model.
CreatorName(IPublishedContent)
Gets the name of the content item creator.
public static string? CreatorName(this IPublishedContent content)
  Parameters
contentIPublishedContentThe content item.
Returns
CultureDate(IPublishedContent, string?)
Gets the culture date of the content item.
public static DateTime CultureDate(this IPublishedContent content, string? culture = null)
  Parameters
contentIPublishedContentThe content item.
culturestringThe specific culture to get the name for. If null is used the current culture is used (Default is null).
Returns
Descendant(IPublishedContent, int, string?)
public static IPublishedContent? Descendant(this IPublishedContent content, int level, string? culture = null)
  Parameters
Returns
- IPublishedContent
 
Descendant(IPublishedContent, string?)
public static IPublishedContent? Descendant(this IPublishedContent content, string? culture = null)
  Parameters
contentIPublishedContentculturestring
Returns
- IPublishedContent
 
DescendantOfType(IPublishedContent, string, string?)
public static IPublishedContent? DescendantOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
  Parameters
Returns
- IPublishedContent
 
DescendantOrSelf(IPublishedContent, int, string?)
public static IPublishedContent? DescendantOrSelf(this IPublishedContent content, int level, string? culture = null)
  Parameters
Returns
- IPublishedContent
 
DescendantOrSelf(IPublishedContent, string?)
public static IPublishedContent DescendantOrSelf(this IPublishedContent content, string? culture = null)
  Parameters
contentIPublishedContentculturestring
Returns
- IPublishedContent
 
DescendantOrSelfOfType(IPublishedContent, string, string?)
public static IPublishedContent? DescendantOrSelfOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
  Parameters
Returns
- IPublishedContent
 
DescendantOrSelf<T>(IPublishedContent, int, string?)
public static T? DescendantOrSelf<T>(this IPublishedContent content, int level, string? culture = null) where T : class, IPublishedContent
  Parameters
Returns
- T
 
Type Parameters
T
DescendantOrSelf<T>(IPublishedContent, string?)
public static T? DescendantOrSelf<T>(this IPublishedContent content, string? culture = null) where T : class, IPublishedContent
  Parameters
contentIPublishedContentculturestring
Returns
- T
 
Type Parameters
T
Descendant<T>(IPublishedContent, int, string?)
public static T? Descendant<T>(this IPublishedContent content, int level, string? culture = null) where T : class, IPublishedContent
  Parameters
Returns
- T
 
Type Parameters
T
Descendant<T>(IPublishedContent, string?)
public static T? Descendant<T>(this IPublishedContent content, string? culture = null) where T : class, IPublishedContent
  Parameters
contentIPublishedContentculturestring
Returns
- T
 
Type Parameters
T
Descendants(IPublishedContent, int, string?)
public static IEnumerable<IPublishedContent> Descendants(this IPublishedContent content, int level, string? culture = null)
  Parameters
Returns
- IEnumerable<IPublishedContent>
 
Descendants(IPublishedContent, string?)
public static IEnumerable<IPublishedContent> Descendants(this IPublishedContent content, string? culture = null)
  Parameters
contentIPublishedContentculturestring
Returns
- IEnumerable<IPublishedContent>
 
DescendantsOfType(IPublishedContent, string, string?)
public static IEnumerable<IPublishedContent> DescendantsOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
  Parameters
Returns
- IEnumerable<IPublishedContent>
 
DescendantsOrSelf(IPublishedContent, int, string?)
public static IEnumerable<IPublishedContent> DescendantsOrSelf(this IPublishedContent content, int level, string? culture = null)
  Parameters
Returns
- IEnumerable<IPublishedContent>
 
DescendantsOrSelf(IPublishedContent, string?)
public static IEnumerable<IPublishedContent> DescendantsOrSelf(this IPublishedContent content, string? culture = null)
  Parameters
contentIPublishedContentculturestring
Returns
- IEnumerable<IPublishedContent>
 
DescendantsOrSelfOfType(IEnumerable<IPublishedContent>, string, string?)
Returns all DescendantsOrSelf of all content referenced
public static IEnumerable<IPublishedContent> DescendantsOrSelfOfType(this IEnumerable<IPublishedContent> parentNodes, string docTypeAlias, string? culture = null)
  Parameters
parentNodesIEnumerable<IPublishedContent>docTypeAliasstringculturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- IEnumerable<IPublishedContent>
 
Remarks
This can be useful in order to return all nodes in an entire site by a type when combined with TypedContentAtRoot
DescendantsOrSelfOfType(IPublishedContent, string, string?)
public static IEnumerable<IPublishedContent> DescendantsOrSelfOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
  Parameters
Returns
- IEnumerable<IPublishedContent>
 
DescendantsOrSelf<T>(IEnumerable<IPublishedContent>, string?)
Returns all DescendantsOrSelf of all content referenced
public static IEnumerable<T> DescendantsOrSelf<T>(this IEnumerable<IPublishedContent> parentNodes, string? culture = null) where T : class, IPublishedContent
  Parameters
parentNodesIEnumerable<IPublishedContent>culturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- IEnumerable<T>
 
Type Parameters
T
Remarks
This can be useful in order to return all nodes in an entire site by a type when combined with TypedContentAtRoot
DescendantsOrSelf<T>(IPublishedContent, int, string?)
public static IEnumerable<T> DescendantsOrSelf<T>(this IPublishedContent content, int level, string? culture = null) where T : class, IPublishedContent
  Parameters
Returns
- IEnumerable<T>
 
Type Parameters
T
DescendantsOrSelf<T>(IPublishedContent, string?)
public static IEnumerable<T> DescendantsOrSelf<T>(this IPublishedContent content, string? culture = null) where T : class, IPublishedContent
  Parameters
contentIPublishedContentculturestring
Returns
- IEnumerable<T>
 
Type Parameters
T
Descendants<T>(IPublishedContent, int, string?)
public static IEnumerable<T> Descendants<T>(this IPublishedContent content, int level, string? culture = null) where T : class, IPublishedContent
  Parameters
Returns
- IEnumerable<T>
 
Type Parameters
T
Descendants<T>(IPublishedContent, string?)
public static IEnumerable<T> Descendants<T>(this IPublishedContent content, string? culture = null) where T : class, IPublishedContent
  Parameters
contentIPublishedContentculturestring
Returns
- IEnumerable<T>
 
Type Parameters
T
FirstChild(IPublishedContent, Func<IPublishedContent, bool>, string?)
public static IPublishedContent? FirstChild(this IPublishedContent content, Func<IPublishedContent, bool> predicate, string? culture = null)
  Parameters
Returns
- IPublishedContent
 
FirstChild(IPublishedContent, Guid, string?)
public static IPublishedContent? FirstChild(this IPublishedContent content, Guid uniqueId, string? culture = null)
  Parameters
Returns
- IPublishedContent
 
FirstChild(IPublishedContent, string?)
public static IPublishedContent? FirstChild(this IPublishedContent content, string? culture = null)
  Parameters
contentIPublishedContentculturestring
Returns
- IPublishedContent
 
FirstChildOfType(IPublishedContent, string, string?)
Gets the first child of the content, of a given content type.
public static IPublishedContent? FirstChildOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
  Parameters
Returns
- IPublishedContent
 
FirstChild<T>(IPublishedContent, Func<T, bool>, string?)
public static T? FirstChild<T>(this IPublishedContent content, Func<T, bool> predicate, string? culture = null) where T : class, IPublishedContent
  Parameters
Returns
- T
 
Type Parameters
T
FirstChild<T>(IPublishedContent, string?)
public static T? FirstChild<T>(this IPublishedContent content, string? culture = null) where T : class, IPublishedContent
  Parameters
contentIPublishedContentculturestring
Returns
- T
 
Type Parameters
T
GetCultureFromDomains(IPublishedContent, Uri?)
Gets the culture assigned to a document by domains, in the context of a current Uri.
public static string? GetCultureFromDomains(this IPublishedContent content, Uri? current = null)
  Parameters
contentIPublishedContentThe document.
currentUriAn optional current Uri.
Returns
- string
 The culture assigned to the document by domains.
Remarks
In 1:1 multilingual setup, a document contains several cultures (there is not one document per culture), and domains, withing the context of a current Uri, assign a culture to that document.
GetTemplateAlias(IPublishedContent)
Returns the current template Alias
public static string GetTemplateAlias(this IPublishedContent content)
  Parameters
contentIPublishedContent
Returns
- string
 Empty string if none is set.
HasValue(IPublishedContent, string, string?, string?, Fallback)
Gets a value indicating whether the content has a value for a property identified by its alias.
public static bool HasValue(this IPublishedContent content, string alias, string? culture = null, string? segment = null, Fallback fallback = null)
  Parameters
contentIPublishedContentThe content.
aliasstringThe property alias.
culturestringThe variation language.
segmentstringThe variation segment.
fallbackFallbackOptional fallback strategy.
Returns
- bool
 A value indicating whether the content has a value for the property identified by the alias.
Remarks
Returns true if HasValue is true, or a fallback strategy can provide a value.
IsAllowedTemplate(IPublishedContent, bool, bool, int)
public static bool IsAllowedTemplate(this IPublishedContent content, bool disableAlternativeTemplates, bool validateAlternativeTemplates, int templateId)
  Parameters
contentIPublishedContentdisableAlternativeTemplatesboolvalidateAlternativeTemplatesbooltemplateIdint
Returns
IsAllowedTemplate(IPublishedContent, bool, bool, string)
public static bool IsAllowedTemplate(this IPublishedContent content, bool disableAlternativeTemplates, bool validateAlternativeTemplates, string templateAlias)
  Parameters
contentIPublishedContentdisableAlternativeTemplatesboolvalidateAlternativeTemplatesbooltemplateAliasstring
Returns
IsAllowedTemplate(IPublishedContent, int)
public static bool IsAllowedTemplate(this IPublishedContent content, int templateId)
  Parameters
contentIPublishedContenttemplateIdint
Returns
IsAllowedTemplate(IPublishedContent, string)
public static bool IsAllowedTemplate(this IPublishedContent content, string templateAlias)
  Parameters
contentIPublishedContenttemplateAliasstring
Returns
MediaUrl(IPublishedContent, string?, UrlMode, string)
Gets the url for a media.
public static string MediaUrl(this IPublishedContent content, string? culture = null, UrlMode mode = 0, string propertyAlias = "umbracoFile")
  Parameters
contentIPublishedContentThe content item.
culturestringThe culture (use current culture by default).
modeUrlModeThe url mode (use site configuration by default).
propertyAliasstringThe alias of the property (use 'umbracoFile' by default).
Returns
- string
 The url for the media.
Remarks
The value of this property is contextual. It depends on the 'current' request uri, if any. In addition, when the content type is multi-lingual, this is the url for the specified culture. Otherwise, it is the invariant url.
Name(IPublishedContent, string?)
Gets the name of the content item.
public static string? Name(this IPublishedContent content, string? culture = null)
  Parameters
contentIPublishedContentThe content item.
culturestringThe specific culture to get the name for. If null is used the current culture is used (Default is null).
Returns
SearchChildren(IPublishedContent, string, string?)
public static IEnumerable<PublishedSearchResult> SearchChildren(this IPublishedContent content, string term, string? indexName = null)
  Parameters
Returns
- IEnumerable<PublishedSearchResult>
 
SearchDescendants(IPublishedContent, string, string?)
public static IEnumerable<PublishedSearchResult> SearchDescendants(this IPublishedContent content, string term, string? indexName = null)
  Parameters
Returns
- IEnumerable<PublishedSearchResult>
 
Siblings(IPublishedContent, string?)
Gets the siblings of the content.
public static IEnumerable<IPublishedContent>? Siblings(this IPublishedContent content, string? culture = null)
  Parameters
contentIPublishedContentThe content.
culturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- IEnumerable<IPublishedContent>
 The siblings of the content.
Remarks
Note that in V7 this method also return the content node self.
SiblingsAndSelf(IPublishedContent, string?)
Gets the siblings of the content including the node itself to indicate the position.
public static IEnumerable<IPublishedContent>? SiblingsAndSelf(this IPublishedContent content, string? culture = null)
  Parameters
contentIPublishedContentThe content.
culturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- IEnumerable<IPublishedContent>
 The siblings of the content including the node itself.
SiblingsAndSelfOfType(IPublishedContent, string, string?)
Gets the siblings of the content including the node itself to indicate the position, of a given content type.
public static IEnumerable<IPublishedContent>? SiblingsAndSelfOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
  Parameters
contentIPublishedContentThe content.
contentTypeAliasstringThe content type alias.
culturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- IEnumerable<IPublishedContent>
 The siblings of the content including the node itself, of the given content type.
SiblingsAndSelf<T>(IPublishedContent, string?)
Gets the siblings of the content including the node itself to indicate the position, of a given content type.
public static IEnumerable<T>? SiblingsAndSelf<T>(this IPublishedContent content, string? culture = null) where T : class, IPublishedContent
  Parameters
contentIPublishedContentThe content.
culturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- IEnumerable<T>
 The siblings of the content including the node itself, of the given content type.
Type Parameters
TThe content type.
SiblingsOfType(IPublishedContent, string, string?)
Gets the siblings of the content, of a given content type.
public static IEnumerable<IPublishedContent>? SiblingsOfType(this IPublishedContent content, string contentTypeAlias, string? culture = null)
  Parameters
contentIPublishedContentThe content.
contentTypeAliasstringThe content type alias.
culturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- IEnumerable<IPublishedContent>
 The siblings of the content, of the given content type.
Remarks
Note that in V7 this method also return the content node self.
Siblings<T>(IPublishedContent, string?)
Gets the siblings of the content, of a given content type.
public static IEnumerable<T>? Siblings<T>(this IPublishedContent content, string? culture = null) where T : class, IPublishedContent
  Parameters
contentIPublishedContentThe content.
culturestringThe specific culture to filter for. If null is used the current culture is used. (Default is null)
Returns
- IEnumerable<T>
 The siblings of the content, of the given content type.
Type Parameters
TThe content type.
Remarks
Note that in V7 this method also return the content node self.
Url(IPublishedContent, string?, UrlMode)
Gets the url of the content item.
public static string Url(this IPublishedContent content, string? culture = null, UrlMode mode = 0)
  Parameters
contentIPublishedContentculturestringmodeUrlMode
Returns
Remarks
If the content item is a document, then this method returns the url of the document. If it is a media, then this methods return the media url for the 'umbracoFile' property. Use the MediaUrl() method to get the media url for other properties.
The value of this property is contextual. It depends on the 'current' request uri, if any. In addition, when the content type is multi-lingual, this is the url for the specified culture. Otherwise, it is the invariant url.
UrlSegment(IPublishedContent, string?)
Gets the URL segment of the content item.
public static string? UrlSegment(this IPublishedContent content, string? culture = null)
  Parameters
contentIPublishedContentThe content item.
culturestringThe specific culture to get the URL segment for. If null is used the current culture is used (Default is null).
Returns
Value(IPublishedContent, string, string?, string?, Fallback?, object?)
Gets the value of a content's property identified by its alias, if it exists, otherwise a default value.
public static object? Value(this IPublishedContent content, string alias, string? culture = null, string? segment = null, Fallback? fallback = null, object? defaultValue = null)
  Parameters
contentIPublishedContentThe content.
aliasstringThe property alias.
culturestringThe variation language.
segmentstringThe variation segment.
fallbackFallbackOptional fallback strategy.
defaultValueobjectThe default value.
Returns
- object
 The value of the content's property identified by the alias, if it exists, otherwise a default value.
Value<T>(IPublishedContent, 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 IPublishedContent content, string alias, string? culture = null, string? segment = null, Fallback? fallback = null, T? defaultValue = default)
  Parameters
contentIPublishedContentThe content.
aliasstringThe property alias.
culturestringThe variation language.
segmentstringThe variation segment.
fallbackFallbackOptional fallback strategy.
defaultValueTThe default value.
Returns
- T
 The value of the content's property identified by the alias, converted to the specified type.
Type Parameters
TThe target property type.
WriterName(IPublishedContent)
Gets the name of the content item writer.
public static string? WriterName(this IPublishedContent content)
  Parameters
contentIPublishedContentThe content item.