namespace CustomUmbracoFuntionality.XSLTExtensions
{
public class SomeExtension
{
///
/// Returns the root for the current site
///
public static string GetFullUrl(int nodeId)
{
return SomeHelper.GetFullUrl(nodeId);
}
}
}
[/code]
Then I modified the XsltExtensions.Config file
[code][/code]
Then you can use it in your XSLT using [code]Alias:Method[/code] With 4.0.1 XSLTExtensions declarations are automaticly added to the XSLT in 4.0 you have to do that manually
Using own extension in template's C# code [solved]
Hello,
how can I use my own template from c# code in template?
I try MyExtension.myMethod() but it dosn't work.
Petr
Hi Petr,
DId that the other day by creating a class
[code]
namespace CustomUmbracoFuntionality.XSLTExtensions
{
public class SomeExtension
{
///
/// Returns the root for the current site
///
public static string GetFullUrl(int nodeId)
{
return SomeHelper.GetFullUrl(nodeId);
}
}
}
[/code]
Then I modified the XsltExtensions.Config file
[code][/code]
Then you can use it in your XSLT using [code]Alias:Method[/code] With 4.0.1 XSLTExtensions declarations are automaticly added to the XSLT in 4.0 you have to do that manually
[code]
]>
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:SomeExtension="urn:SomeExtension"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library SomeExtension">
[/code]
BTW You need a Macro for this.
Hi Richard,
Thank you, I allready know how to use extensions from xslt,
but in v4 I don't need macro, I can use this code in my template directly.
[code]
<%@ Import Namespace="MyExtensionNamespace" %>
[/code]
And it works :-)
Petr
is working on a reply...