We are working on Tridion 2011 SP1 and we always used DWT (Dreamweaver templates). We have a huge collection of usefull custom functions that we are using accross various dreaweaver templates.
Due to issues with getting component links inside dreamweaver templates, we are now started by using Razor templates. Everything goes well, but is there possibility to reuse all our custom functions that we have in DWT?
Since we are using Media Manager, they provided us the following function to get the url of an image in Media Manager via a Custom DWT Function. But in our Razor templates, we cannot use them anymore.
Custom function example in DWT:
@@GetExternalContentLibraryDirectLink("tcm:6-12345")@@
@@RootUri()@@
A lot of these functions can be replaced with @function {} in Razor. But we have really complex functions that are using the Engine and Package. And we have the GetExternalContentLibraryDirectLink where we don't have the source of.
This function is an example, the class inherits of IFunctionSource and the dll is added to the GAC.
public void Initialize(Engine engine, Package package) {
m_Engine = engine;
m_Package = package;
}
[TemplateCallable]
public string RootUri() {
return GetPublication().RootStructureGroup.PublishLocationUrl;
}