While I'm studying the linq-to-umbraco features I still have to deliver on a project so:
Basically I'd like to render different umbraco xslt files, based on decisions made in a masterpage codebehind. The xslt transformation has to take place like when the transformation is done by an umbraco:Macro, but I'd like to dynamically select which xslt file is used, or alternatively which alias is used for the macro, so I can have multiple macros each calling different xslt-files.
I've tried setting the macro alias in code like this:
MacroId.Alias = "MyMacroAlias";
Both i Page_Load and Page_Prerender, but this results in the macro not running, it just outputs "<Macro: (,)>" into the page output.
What I'd really like to do was use the Api to run the xslt transformation, so that I didn't need the macro at all, but I haven't been able to turn up any pages explaining how that can be done.
i have the exact same problem. I wan´t to render a document with a xslt file direct from my code-behind-file. I know i can use xslttransform in .NET, but is there a "right" way to do it in Umbraco. Have you found any solution yet?
Take a look at xsltResult project, it allow you to specify xslt style as parameter, maybe it can be changed at runtime. But it use caching by default, so don't remember to disable it.
Checked out the locator sourcecode (or actually I chose the lazy way, downloaded the package, and popped the Nibble.Umb.Locator.dll open in reflector). I presume the code you're talking about is
So went to check if there was any issues around this i codeplex. Turns out there was one, which I would recommend you voted up, the issue can be found here. This search also turned up a page written by Kasper B outlining a method to achieve something like the above umbraco-tag.
Easiest way to render xslt file from code
While I'm studying the linq-to-umbraco features I still have to deliver on a project so:
Basically I'd like to render different umbraco xslt files, based on decisions made in a masterpage codebehind. The xslt transformation has to take place like when the transformation is done by an umbraco:Macro, but I'd like to dynamically select which xslt file is used, or alternatively which alias is used for the macro, so I can have multiple macros each calling different xslt-files.
I've tried setting the macro alias in code like this:
Both i Page_Load and Page_Prerender, but this results in the macro not running, it just outputs "<Macro: (,)>" into the page output.
What I'd really like to do was use the Api to run the xslt transformation, so that I didn't need the macro at all, but I haven't been able to turn up any pages explaining how that can be done.
Any ideas?
Regards
Jesper Hauge
Hi Jesper,
i have the exact same problem. I wan´t to render a document with a xslt file direct from my code-behind-file. I know i can use xslttransform in .NET, but is there a "right" way to do it in Umbraco. Have you found any solution yet?
Regards
René Pjengaard
Hi René,
Check out the locator sourecode, I do some xslt transformations from a usercontrol in there.
http://locator4umbraco.codeplex.com/
Take a look at xsltResult project, it allow you to specify xslt style as parameter, maybe it can be changed at runtime. But it use caching by default, so don't remember to disable it.
Petr
Thanks Tim
Checked out the locator sourcecode (or actually I chose the lazy way, downloaded the package, and popped the Nibble.Umb.Locator.dll open in reflector). I presume the code you're talking about is
in the Locator usercontrol Page_load. Looks like it is exactly what I was asking for.
However this still requires the creation of a macro, and it got me thinking how much nicer it would be to be able to do this with an umbraco tag like,
So went to check if there was any issues around this i codeplex. Turns out there was one, which I would recommend you voted up, the issue can be found here. This search also turned up a page written by Kasper B outlining a method to achieve something like the above umbraco-tag.
Regards
Jesper Hauge
And thanks petr - checking out the XsltResult project right now!
As far as I can see it does exactly what I didn't know I wanted until now.
Regards
Jesper
P.S. Giving the answer to Petr (partly because I'm a big fan of Mr.Incredible)
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.