Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter Duncanson 430 posts 1360 karma points c-trib
    Aug 03, 2009 @ 14:41
    Peter Duncanson
    0

    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

  • Richard Soeteman 4047 posts 12900 karma points MVP 2x
    Aug 03, 2009 @ 14:55
    Richard Soeteman
    1

    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

    <

     

    xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO macroAlias=&quot;ShowContentImage&quot; &gt; &lt;/?UMBRACO_MACRO&gt;', $currentPage/@id)" disable-output-escaping="yes"/>

     Hope this helps you,

    Richard

  • Peter Duncanson 430 posts 1360 karma points c-trib
    Aug 03, 2009 @ 15:08
    Peter Duncanson
    0

    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 :)

  • Peter Duncanson 430 posts 1360 karma points c-trib
    Aug 03, 2009 @ 15:22
    Peter Duncanson
    0

    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.

  • Richard Soeteman 4047 posts 12900 karma points MVP 2x
    Aug 03, 2009 @ 15:38
    Richard Soeteman
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft