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.nodes
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.Nodes" alias="ucomponents.nodes" />
...
</XsltExtensions>
Here are available methods in the Nodes
library:
Gets the expiry date of a node; e.g. when the content is scheduled to be unpublished.
Returns: Returns the expiry date of a node.
| Name | Type | Notes |
|——|——|——-|
| nodeId | System.Int32
| |
<xsl:value-of select="ucomponents.nodes:GetExpireDate($currentPage/@id)" />
Gets the node Id by URL.
Returns: Returns the node Id for a given URL.
| Name | Type | Notes |
|——|——|——-|
| url | System.String
| |
<xsl:value-of select="ucomponents.nodes:GetNodeIdByUrl('/nice-url/')" />
Gets the node id by path level.
Returns: Returns the node id for a given path level.
| Name | Type | Notes |
|——|——|——-|
| path | System.String
| |
| level | System.Int32
| |
<xsl:value-of select="ucomponents.nodes:GetNodeIdByPathLevel('-1,1059,1083,1085', 1)" />
Gets the release date of a node (to be published).
Returns: Returns the release date of a node.
| Name | Type | Notes |
|——|——|——-|
| nodeId | System.Int32
| |
<xsl:value-of select="ucomponents.nodes:GetReleaseDate(1099)" />
Gets the unique id (System.Guid
) of a node.
Returns: Returns the unique id of a node.
| Name | Type | Notes |
|——|——|——-|
| nodeId | System.Int32
| |
<xsl:value-of select="ucomponents.nodes:GetUniqueId($currentPage/@id)" />
Gets a list of XML nodes by CSV (with an option to persist the order).
Returns: Returns an XPathNodeIterator
of the nodes from the CSV list.
| Name | Type | Notes |
|——|——|——-|
| csv | System.String
| |
| persistOrder | System.Boolean
| (optional - defaults to false
) |
<ul>
<xsl:for-each select="ucomponents.nodes:GetXmlNodeByCsv('1085,1086,1087,1088', false())">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
</li>
</xsl:for-each>
</ul>
Gets the XML node by path level.
Returns: Returns an XML node by path level.
| Name | Type | Notes |
|——|——|——-|
| path | System.String
| |
| level | System.Int32
| |
<xsl:variable name="homepage" select="ucomponents.nodes:GetXmlNodeByPathLevel($currentPage/@path, 1)" />
<xsl:value-of select="$homepage/@nodeName" />
Gets the XML node by URL.
Returns: Returns the XML for the node.
| Name | Type | Notes |
|——|——|——-|
| url | System.String
| |
<xsl:variable name="node" select="ucomponents.nodes:GetXmlNodeByUrl('/nice-url/')" />
<xsl:value-of select="$node/@nodeName" />