14 September 2006

using Sitecore.Kernel.Webutils

Webutils functions can be used as helper functions as well. In order to get the url of the server, we can use it as follows:

install it in web.config:

<xslExtensions>
...
<extension mode="on" type="Sitecore.Web.WebUtil, Sitecore.Kernel" namespace="http://www.sitecore.net/webutil" singleInstance="true" />
</xslExtensions>


declare it in your xslt:

xmlns:webutil="http://www.sitecore.net/webutil"


then use it (example from a "print page" footer):

<xsl:text>Artiklens placering: </xsl:text><xsl:value-of select="webutil:GetServerUrl()" /><xsl:value-of select="sc:path(.)" />

3 comments:

Jukka-Pekka Keisala said...

There is also GetRawUrl Method, that returns complete url including querystrings.

Sander Falise said...

Wouldn't it be nice if there were a complete list of classes that implement the IXslExtension interface (and as such can be used as helper classes) ...

Sander Falise said...

It seems there is a way to show this :
* Open VS2005
* Go to View - Object browser
* In the 'Browse' dropdown, choose 'Custom Component Set'
* Click the [...] button next to the list and browse to the SiteCore.Kernel.dll
* In the settings dropdown (last item on the 'Browse' line), check 'Show derived types'
* In the list of objects below the 'Browse' line, scroll to (or search) for the 'Sitecore.Xml.IXslExtension' interface
* Open the 'Derived Types' folder to discover it's empty ... why??

Anybody know how to fix this? I can't find any interface that has derived types but it does work if you select the '.NET Framework' in the 'Browse' dropdown.