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.Urls" alias="ucomponents.urls" />
...
</XsltExtensions>
Here are available methods in the Urls
library:
Here are available events in the Urls
library:
Appends the alternative template to the url as a querystring or folder instead of a querystring. Is “use directory urls” aware if set. Returns: Complete url with alt template merged in.
| Name | Type | Notes |
|——|——|——-|
| url | System.String
| |
| altTemplateAlias | System.String
| |
| useQueryString | System.Boolean
| (optional - defaults to false
) |
| useDirectoryUrls | System.Boolean
| (optional - defaults to GlobalSettings.UseDirectoryUrls
) |
<xsl:value-of select="ucomponents.urls:AddAltTemplate(umbraco.library:NiceUrl($currentPage/@id), 'rss', false())" />
Appends or updates a query string value to supplied Url Returns: The updated Url
| Name | Type | Notes |
|——|——|——-|
| url | System.String
| (optional - defaults to Request.RawUrl
) |
| key | System.String
| |
| value | System.String
| |
<xsl:value-of select="ucomponents.urls:AppendOrUpdateQueryString(umbraco.library:NiceUrl($currentPage/@id), 'page', '2')" />
Formats the URL - replacing characters in the string to make a ‘safe’ URL. Returns: Returns a ‘safe’ URL, removing illegal characters.
| Name | Type | Notes |
|——|——|——-|
| input | System.String
| |
<xsl:value-of select="ucomponents.urls:FormatUrl($currentPage/@nodeName)" />
Returns a nicely formatted Url for a given node and alternative template. Returns: The NiceUrl for the node id.
This method triggers the OnBeforeNiceUrlGenerated andOnAfterNiceUrlGenerated events.
| Name | Type | Notes |
|——|——|——-|
| nodeId | System.Int32
| |
| altTemplateAlias | System.String
| (optional - defaults to null
) |
| useQueryString | System.Boolean
| (optional - defaults to false
) |
<xsl:value-of select="ucomponents.urls:NiceUrl($currentPage/@id, 'rss', false())" />
Gets the hostname of the node Id. Returns: Returns the hostname for the node Id.
| Name | Type | Notes |
|——|——|——-|
| nodeId | System.Int32
| |
<xsl:value-of select="ucomponents.urls:GetHostName($currentPage/@id)" />
Obsolete: Please use ucomponents.nodes:GetNodeIdByUrl
.
Gets the text by URL. Returns: Returns the text (System.String) from a given URL.
| Name | Type | Notes |
|——|——|——-|
| url | System.String
| |
<xsl:value-of select="ucomponents.urls:GetTextByUrl('http://ucomponents.github.io/LICENSE')" />
Obsolete: Please use ucomponents.nodes:GetXmlNodeByUrl
.
Guesses the NiceUrl based on the node id. Returns: Returns a guestimate of the NiceUrl for a node id.
GuessNiceUrl
is not very performant when attempting to guess the URL for unpublished nodes.
Do not over-use this method. It makes many database calls and will be slow!
| Name | Type | Notes |
|——|——|——-|
| nodeId | System.Int32
| |
<xsl:value-of select="ucomponents.urls:GuessNiceUrl(1066)" />
Dispatches a BeforeNiceUrlGenerated event.
| Name | Type | Notes |
|——|——|——-|
| nodeId | System.Int32
| |
uComponents.XsltExtensions.Urls.BeforeNiceUrlGenerated += Urls_BeforeNiceUrlGenerated;
Dispatches an AfterNiceUrlGenerated event.
| Name | Type | Notes |
|——|——|——-|
| nodeId | System.Int32
| |
| url | System.String
| |
uComponents.XsltExtensions.Urls.AfterNiceUrlGenerated += Urls_AfterNiceUrlGenerated;