As of uComponents v6.0.0 all XSLT extensions are automatically registered with Umbraco. Newly created XSLT files (in the back-office) will already contain the appropriate namespaces. For existing XSLT files, you will still need to add the ucomponents.cms
namespace.
Enabling the XSLT extension for use in your XSLT templates.
Add the following XML snippet to your ~/config/xsltExtensions.config
file:
<XsltExtensions>
...
<ext assembly="uComponents.XsltExtensions" type="uComponents.XsltExtensions.Cms" alias="ucomponents.cms" />
...
</XsltExtensions>
Here are available methods in the Cms
library:
Returns an XPathNodeIterator
of all the data types created in Umbraco.
Returns: A node-set of all the data types used within Umbraco.
<ul>
<xsl:for-each select="ucomponents.cms:GetDataTypes()/DataType">
<li>
<xsl:value-of select="@Name" />
</li>
</xsl:for-each>
</ul>
Returns an XPathNodeIterator
of the specified data-type by a Guid
(string
).
Returns: A node-set of the specified data-type
| Name | Type | Notes |
|——|——|——-|
| dataTypeGuid | System.String
| |
<xsl:variable name="dataType" select="ucomponents.cms:GetDataTypeByGuid('0CC0EBA1-9960-42C9-BF9B-60E150B429AE')" />
<xsl:value-of select="$dataType/@Name" />
Returns an XPathNodeIterator
of the specified data-type by Id.
Returns: A node-set of the specified data-type
| Name | Type | Notes |
|——|——|——-|
| dataTypeId | System.Int32
| |
<xsl:variable name="dataType" select="ucomponents.cms:GetDataTypeById(-88)" />
<xsl:value-of select="$dataType/@Name" />
Returns an XPathNodeIterator
of all the document types created in Umbraco.
Returns: A node-set of all the document types used within Umbraco.
| Name | Type | Notes |
|——|——|——-|
| includeTabs | System.Boolean
| (optional - defaults to false
) |
| includePropertyTypes | System.Boolean
| (optional - defaults to false
) |
| includeAllowedTemplates | System.Boolean
| (optional - defaults to false
) |
<ul>
<xsl:for-each select="ucomponents.cms:GetDocumentTypes()/DocumentType">
<li>
<xsl:value-of select="@name" />
</li>
</xsl:for-each>
</ul>
Returns an XPathNodeIterator of the specified document-type.
Returns: A node-set of the specified document-type.
| Name | Type | Notes |
|——|——|——-|
| docTypeId | System.Int32
| |
| includeTabs | System.Boolean
| |
| includePropertyTypes | System.Boolean
| |
| includeAllowedTemplates | System.Boolean
| |
<xsl:variable name="docType" select="ucomponents.cms:GetDocumentType(1054, false(), true(), false())" />
<xsl:value-of select="$docType/@name" />
Returns an XPathNodeIterator
of all the languages created in Umbraco.
Returns: A node-set of all the languages used within Umbraco
<ul>
<xsl:for-each select="ucomponents.cms:GetLanguages()/Language">
<li>
<xsl:value-of select="@FriendlyName" />
</li>
</xsl:for-each>
</ul>
Gets the language by id.
Returns: A node-set of the specified language.
| Name | Type | Notes |
|——|——|——-|
| languageId | System.Int32
| |
<xsl:variable name="language" select="ucomponents.cms:GetLanguage(1)" />
<xsl:value-of select="$language/@FriendlyName" />
Gets the language by culture code.
Returns: Returns a node-set of the specified language.
| Name | Type | Notes |
|——|——|——-|
| cultureCode | System.String
| |
<xsl:variable name="language" select="ucomponents.cms:GetLanguageByCultureCode('en-US')" />
<xsl:value-of select="$language/@FriendlyName" />
Gets the language by node id.
Returns: Returns a node-set of the language by the node id.
| Name | Type | Notes |
|——|——|——-|
| nodeId | System.Int32
| |
<xsl:variable name="language" select="ucomponents.cms:GetLanguageByNodeId(1059)" />
<xsl:value-of select="$language/@FriendlyName" />
Gets the language id by node id.
Returns: Returns the id of the language by the node id.
| Name | Type | Notes |
|——|——|——-|
| nodeId | System.Int32
| |
<xsl:value-of select="ucomponents.cms:GetLanguageIdByNodeId(1059)" />
Returns an XPathNodeIterator
of all the macros created in Umbraco.
Returns: A node-set of all the macros used within Umbraco.
<xsl:value-of select="ucomponents.cms:GetMacros()" />
<ul>
<xsl:for-each select="ucomponents.cms:GetMacros()/macro">
<li>
<xsl:value-of select="@name" />
</li>
</xsl:for-each>
</ul>
Returns an XPathNodeIterator
of the specified macro.
Returns: A node-set of the specified macro.
| Name | Type | Notes |
|——|——|——-|
| alias | System.String
| |
<xsl:variable name="macro" select="ucomponents.cms:GetMacro('Breadcrumb')" />
<xsl:value-of select="$macro/@name" />
Returns an XPathNodeIterator
of all the media types created in Umbraco.
Returns: A node-set of all the media types used within Umbraco.
| Name | Type | Notes |
|——|——|——-|
| includeTabs | System.Boolean
| (optional - defaults to false
) |
| includePropertyTypes | System.Boolean
| (optional - defaults to false
) |
<ul>
<xsl:for-each select="ucomponents.cms:GetMediaTypes(false(), false())/MediaType">
<li>
<xsl:value-of select="@name" />
</li>
</xsl:for-each>
</ul>
Returns an XPathNodeIterator
of the specified media-type.
Returns: A node-set of the specified media-type.
| Name | Type | Notes |
|——|——|——-|
| mediaTypeId | System.Int32
| |
| includeTabs | System.Boolean
| |
| includePropertyTypes | System.Boolean
| |
<xsl:variable name="mediaType" select="ucomponents.cms:GetMediaType(1032, false(), false())" />
<xsl:value-of select="$mediaType/@name" />
Returns an XPathNodeIterator
of all the member types created in Umbraco.
Returns: A node-set of all the member types used within Umbraco.
| Name | Type | Notes |
|——|——|——-|
| includeTabs | System.Boolean
| (optional) |
| includePropertyTypes | System.Boolean
| (optional) |
<ul>
<xsl:for-each select="ucomponents.cms:GetMemberTypes(false(), false())/MemberType">
<li>
<xsl:value-of select="@name" />
</li>
</xsl:for-each>
</ul>
Returns an XPathNodeIterator
of the specified member-type.
Returns: A node-set of the specified member-type.
| Name | Type | Notes |
|——|——|——-|
| memberTypeId | System.Int32
| |
| includeTabs | System.Boolean
| |
| includePropertyTypes | System.Boolean
| |
<xsl:variable name="member" select="ucomponents.cms:GetMemberType(1066, false(), false())" />
<xsl:value-of select="$member/@name" />
Gets the templates.
Returns: Returns an XML structure of all the templates.
<xsl:value-of select="ucomponents.cms:GetTemplates()" />
<ul>
<xsl:for-each select="ucomponents.cms:GetTemplates()/Template">
<li>
<xsl:value-of select="@Name" />
</li>
</xsl:for-each>
</ul>
Gets the template alias.
Returns: Returns the alias name of the template.
| Name | Type | Notes |
|——|——|——-|
| templateId | System.Int32
| |
<xsl:value-of select="ucomponents.cms:GetTemplateAlias(1045)" />
Gets the template by id.
Returns: Returns an XML structure of the template.
| Name | Type | Notes |
|——|——|——-|
| templateId | System.Int32
| |
<xsl:variable name="template" select="ucomponents.cms:GetTemplateAlias(1045)" />
<xsl:value-of select="$template/@Name" />
Gets the template by alias.
Returns: Returns an XML structure of the template.
| Name | Type | Notes |
|——|——|——-|
| templateAlias | System.String
| |
<xsl:variable name="template" select="ucomponents.cms:GetTemplateByAlias('Homepage')" />
<xsl:value-of select="$template/@Name" />
Gets the template id by alias.
Returns: Returns the template id.
| Name | Type | Notes |
|——|——|——-|
| templateAlias | System.String
| |
<xsl:value-of select="ucomponents.cms:GetTemplateIdByAlias('Homepage')" />
Gets all users.
<ul>
<xsl:for-each select="ucomponents.cms:GetAllUsers()/User">
<li>
<a href="mailto:{@email}">
<xsl:value-of select="@name" />
</a>
</li>
</xsl:for-each>
</ul>
Gets all users by email.
| Name | Type | Notes |
|——|——|——-|
| email | System.String
| |
<ul>
<xsl:for-each select="ucomponents.cms:GetAllUsersByEmail('admin@domain.com')/User">
<li>
<a href="mailto:{@email}">
<xsl:value-of select="@name" />
</a>
</li>
</xsl:for-each>
</ul>
Gets the name of all users by login.
| Name | Type | Notes |
|——|——|——-|
| loginName | System.String
| |
| partialMatch | System.Boolean
| (optional - defaults to false
) |
<ul>
<xsl:for-each select="ucomponents.cms:GetAllUsersByLoginName('admin', false())/User">
<li>
<a href="mailto:{@email}">
<xsl:value-of select="@name" />
</a>
</li>
</xsl:for-each>
</ul>
Gets the user.
| Name | Type | Notes |
|——|——|——-|
| userId | System.Int32
| |
<xsl:variable name="user" select="ucomponents.cms:GetUser(1)" />
<xsl:value-of select="$user/@name" />
Gets the user email.
| Name | Type | Notes |
|——|——|——-|
| userId | System.Int32
| |
<xsl:value-of select="ucomponents.cms:GetUserEmail(1)" />
Gets the user language.
| Name | Type | Notes |
|——|——|——-|
| userId | System.Int32
| |
<xsl:value-of select="ucomponents.cms:GetUserLanguage(1)" />
Gets the name of the user login.
| Name | Type | Notes |
|——|——|——-|
| userId | System.Int32
| |
<xsl:value-of select="ucomponents.cms:GetUserLoginName(1)" />
Gets the name of the user.
| Name | Type | Notes |
|——|——|——-|
| userId | System.Int32
| |
<xsl:value-of select="ucomponents.cms:GetUserName(1)" />
Gets the user type key.
| Name | Type | Notes |
|——|——|——-|
| userId | System.Int32
| |
<xsl:value-of select="ucomponents.cms:GetUserTypeAlias(1)" />
Gets the Content Id by property Id.
Returns: Returns the Content Id.
| Name | Type | Notes |
|——|——|——-|
| propertyId | System.Int32
| |
<xsl:value-of select="ucomponents.cms:GetContentIdByPropertyId(2692)" />
Gets the dictionary item for the specified language id, with a fall-back default value.
Returns: Returns the string value of the dictionary item for the specified language id.
| Name | Type | Notes |
|——|——|——-|
| key | System.String
| |
| languageId | System.Int32
| |
| defaultValue | System.String
| (optional - defaults to string.Empty
) |
<xsl:value-of select="ucomponents.cms:GetDictionaryItem('[XSLTsearch]Heading-SearchResults', 1, 'Search Results')" />
Gets the unique id of a CMSNode
.
Returns: Returns the unique id of a CMSNode
.
| Name | Type | Notes |
|——|——|——-|
| id | System.Int32
| |
<xsl:value-of select="ucomponents.cms:GetUniqueId($currentPage/@id)" />
Checks the Umbraco XML Schema version in use.
Returns: true
if the legacy XML schema is used; otherwise, false
.
<xsl:choose>
<xsl:when test="ucomponents.cms:IsLegacyXmlSchema()">
<xsl:value-of select="$currentPage/data[@alias = 'pageTitle']" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currentPage/pageTitle" />
</xsl:otherwise>
</xsl:choose>
Determines whether Umbraco front-end is in preview mode.
Returns: true
if Umbraco front-end is in preview mode; otherwise, false
.
<xsl:choose>
<xsl:when test="ucomponents.cms:InPreviewMode()">
<p>Display something in preview mode.</p>
</xsl:when>
<xsl:otherwise>
<p>Hide something from preview mode.</p>
</xsl:otherwise>
</xsl:choose>