Fork me on GitHub

Activation

Version 6.0.0 (and above)

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.

Prior to version 6.0.0

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>

Methods

Here are available methods in the Nodes library:


GetExpireDate

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.

Parameters

| Name | Type | Notes | |——|——|——-| | nodeId | System.Int32 | |

XSLT Example

<xsl:value-of select="ucomponents.nodes:GetExpireDate($currentPage/@id)" />

GetNodeIdByUrl

Gets the node Id by URL.
Returns: Returns the node Id for a given URL.

Parameters

| Name | Type | Notes | |——|——|——-| | url | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.nodes:GetNodeIdByUrl('/nice-url/')" />

GetNodeIdByPathLevel

Gets the node id by path level.
Returns: Returns the node id for a given path level.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | | | level | System.Int32 | |

XSLT Example

<xsl:value-of select="ucomponents.nodes:GetNodeIdByPathLevel('-1,1059,1083,1085', 1)" />

GetReleaseDate

Gets the release date of a node (to be published).
Returns: Returns the release date of a node.

Parameters

| Name | Type | Notes | |——|——|——-| | nodeId | System.Int32 | |

XSLT Example

<xsl:value-of select="ucomponents.nodes:GetReleaseDate(1099)" />

GetUniqueId

Gets the unique id (System.Guid) of a node.
Returns: Returns the unique id of a node.

Parameters

| Name | Type | Notes | |——|——|——-| | nodeId | System.Int32 | |

XSLT Example

<xsl:value-of select="ucomponents.nodes:GetUniqueId($currentPage/@id)" />

GetXmlNodeByCsv

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.

Parameters

| Name | Type | Notes | |——|——|——-| | csv | System.String | | | persistOrder | System.Boolean | (optional - defaults to false) |

XSLT Example

<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>

GetXmlNodeByPathLevel

Gets the XML node by path level.
Returns: Returns an XML node by path level.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | | | level | System.Int32 | |

XSLT Example

<xsl:variable name="homepage" select="ucomponents.nodes:GetXmlNodeByPathLevel($currentPage/@path, 1)" />
<xsl:value-of select="$homepage/@nodeName" />

GetXmlNodeByUrl

Gets the XML node by URL.
Returns: Returns the XML for the node.

Parameters

| Name | Type | Notes | |——|——|——-| | url | System.String | |

XSLT Example

<xsl:variable name="node" select="ucomponents.nodes:GetXmlNodeByUrl('/nice-url/')" />
<xsl:value-of select="$node/@nodeName" />