Basically all you have to do is decorate the class with [XsltExtension] and copy the DLL to /bin/. Then when you create XSLT files the appropriate tags will be added at the top to make it work.
In the example in Tim's blog post, that would effectively create a base method that could be called by visiting: yoursite.com/base/TestAlias/HelloWorld, and the output would be "Hello World". They can return XML or strings and can accept parameters like /HelloWorld/param1/param2.
Create own class library (c#) and use methods of them in xslt
Hello,
Is there any useful tutorial which shows how I can use some methods of an own class library in xslt?
I found some examples but i cant get it work.
What i´ve done:
Create a class library in visual studio (with one method). Build it and put the dll into the /bin/ folder
My xslt is looking like this:
Can someone please help?
Everytime i try to use the xsltExtensions.config file i get also an error.
I am using Umbraco 4.7
Doug Robar posted a fantastic guide here
http://blog.percipientstudios.com/2010/11/12/make-an-app_code-xslt-extension-for-umbraco.aspx
Rich
Hi
This one may help you http://our.umbraco.org/forum/developers/api-questions/18836-Media-
Thanks
Pnima
Hi Rich,
I just tryed it by using the following xslt but it still does not work
version="1.0" encoding="UTF-8"?>
xsl:stylesheet [ ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
<xsl:template match="/">
<div>
<xsl:value-of select="ps.Helpers:uploadFileSize('String filePath')" disable-output-escaping="yes"/>
div>
xsl:template>
xsl:stylesheet>
i also copied the .cs file into App_Code
Have i to use any new namespace declarations?
Thanks
One more small tutorial from Tim's blog if you are using 4.6+: http://www.nibble.be/?p=95
Basically all you have to do is decorate the class with [XsltExtension] and copy the DLL to /bin/. Then when you create XSLT files the appropriate tags will be added at the top to make it work.
-Tom
Edit: See Tom's post if you're using >=4.6
ok now it works,
just one question what is
RestExtensionMethod is for exposing your methods /base/ methods that work similar to a REST web service. There's a little information in the wiki: http://our.umbraco.org/wiki/reference/umbraco-base
In the example in Tim's blog post, that would effectively create a base method that could be called by visiting: yoursite.com/base/TestAlias/HelloWorld, and the output would be "Hello World". They can return XML or strings and can accept parameters like /HelloWorld/param1/param2.
-Tom
Ok now i have another question.
I created a new class inside my .cs file but i am not able to select it inside umbraco. Only one class is available
How can i use more than one class?
Ok i got it i have to put in the [XsltExtension] in top of each class
is working on a reply...