Is it possible to nest Marcos? I've a thumbnail macro which renders out a nice img tag with all the right goodness applied to it. Now Ive created an accordian macro which I want to use thumbnails in. Is there a way to have nested macros?
My brain came up with the idea of seperating out XSL functionality and macros by using XSL include files which contain named templates for all the goodies i want to use. Then each macro would just include the XSL file of goodies and call the right template passing in the right params. Is that the way to go? Keeps everything nice and DRY that way? Or is there a sexy Umbraco way I've not found yet.
In the Umbraco Library you will find the RenderMacroContent Method that you can use, Basically you give it a HTML encoded string with the render Macro tag and the ID of the page. Below you'll find an example that I've used to display images. If you don't use macro parameters you can use this example and only change the macroAlias
That great Richard thanks. I really need to poke around some more in that library. Can you suggest some good docs? The ones on the Wiki are a little...short :)
Just out of interest is the XSL include file route a possibility? Might have to have a play around with it and see if it will actually work, all that encoding looks like it could cause trouble.
I would not go for the XSLT Include. Main reason is that the $currentPage param and Macro paramter magic will not happen then. I've seen that the WIKI was not updated for the RenderMacro Method, it's on my todolist
Nested Macros?
Is it possible to nest Marcos? I've a thumbnail macro which renders out a nice img tag with all the right goodness applied to it. Now Ive created an accordian macro which I want to use thumbnails in. Is there a way to have nested macros?
My brain came up with the idea of seperating out XSL functionality and macros by using XSL include files which contain named templates for all the goodies i want to use. Then each macro would just include the XSL file of goodies and call the right template passing in the right params. Is that the way to go? Keeps everything nice and DRY that way? Or is there a sexy Umbraco way I've not found yet.
Cheers
Pete
Hi Pete,
In the Umbraco Library you will find the RenderMacroContent Method that you can use, Basically you give it a HTML encoded string with the render Macro tag and the ID of the page. Below you'll find an example that I've used to display images. If you don't use macro parameters you can use this example and only change the macroAlias
Hope this helps you,
Richard
That great Richard thanks. I really need to poke around some more in that library. Can you suggest some good docs? The ones on the Wiki are a little...short :)
Just out of interest is the XSL include file route a possibility? Might have to have a play around with it and see if it will actually work, all that encoding looks like it could cause trouble.
I would not go for the XSLT Include. Main reason is that the $currentPage param and Macro paramter magic will not happen then. I've seen that the WIKI was not updated for the RenderMacro Method, it's on my todolist
Cheers,
Richard
is working on a reply...