Copied to clipboard

Flag this post as spam?

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


  • Darryl Godden 145 posts 197 karma points
    Jul 09, 2010 @ 12:46
    Darryl Godden
    0

    Call Macro within a XSLT

    Hi all,

    I'm trying to call a macro from within an XSL page, the macro calls another XSL, I can't seem to get it to work, could you help?

    Here is my simple XSL:

    <xsl:variable name="tpd" select="$currentPage/data [@alias = 'TicketPriceDisclaimer']"/>
    
    <xsl:choose>
    <xsl:when test="string-length($tpd)=0">
        Booking &amp; transaction fees may apply, see venue website for details.
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="$tpd"/>
    </xsl:otherwise>
    </xsl:choose>

    I'm trying to call it in another XSLT page here:

    <xsl:value-of select="umbraco.library:RenderMacroContent(TicketPriceDisclaimer, $currentPage/@id)" disable-output-escaping="yes"/>

    Without success, could you advise on where I am going wrong?

    Thanks

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 09, 2010 @ 12:54
    Dirk De Grave
    2

    HI Darryl,

    How does the value for the property with alias = 'TicketPriceDisclaimer' look like?

    First parameter to RenderMacroContent requires you to pass in the macro syntax as you'd normally do when using it from a template (be it in v3 syntax). Find a sample below

    <xsl:variable name="Node" select="$currentPage" />
    <xsl:variable name="macro">
    <xsl:text>&lt;?UMBRACO_MACRO macroAlias="Alias" MacroParameterX="</xsl:text>
    <xsl:value-of select="$Node/data [@alias = 'propertyAlias']" />
    <xsl:text>">&lt;/?UMBRACO_MACRO></xsl:text>
    </xsl:variable>
    <xsl:value-of select="umbraco.library:RenderMacroContent($macro, $Node/@id)" disable-output-escaping="yes" />

    Hope this helps.

    Do be aware of the fact that you can't render a macro that references a user control from xslt!!

    Regards,

    /Dirk

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 09, 2010 @ 12:57
    Jan Skovgaard
    0

    Hi Darryl

    I'm just wondering if your problem could be solved using either xsl:import or xsl:include (can never remember the difference between those two)?

    /Jan

  • Darryl Godden 145 posts 197 karma points
    Jul 09, 2010 @ 13:03
    Darryl Godden
    0

    No parameters in TicketPriceDisclaimer, however you got me going in the right direction, thank you!

    <xsl:variable name="Node" select="$currentPage" />
            <xsl:variable name="macro">
            <xsl:text>&lt;?UMBRACO_MACRO macroAlias="TicketPriceDisclaimer" </xsl:text>
            <xsl:text>">&lt;/?UMBRACO_MACRO></xsl:text>
            </xsl:variable>
            <xsl:value-of select="umbraco.library:RenderMacroContent($macro, $Node/@id)" disable-output-escaping="yes" />
Please Sign in or register to post replies

Write your reply to:

Draft