Copied to clipboard

Flag this post as spam?

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


  • Garrett Fisher 341 posts 496 karma points
    Oct 05, 2016 @ 17:07
    Garrett Fisher
    0

    Calling a Macro Inside an XSLT Macro

    Hi folks--

    I searched around the interwebs quite a lot for this problem but haven't yet got something working so I am coming into the forum hoping for some better help.

    I have a Macro which pulls in / imports a remote Javascript from a CRM (Ggiya) CDN server; this script writes a "Register" link to the home page. The client has asked for a way to turn this "On or off". So I needed to create a Macro called "Enablement", which maps to an XSLT file, so that I can check this boolean field's value, and takes the other macro name as a parameter, and pulls in that other macro. But it's not working properly.

    To get it going, I have created a true/false field on the home page document type and checked the box and republished the home page and then called the Enablement macro from the masterpage template instead of the macro whose name I am now passing in to the Enablement macro, but when I refresh the home page on the front end, I am just getting this:

    Instead of the actual output of the macro whose name I am passing in. Here is the XSLT code from the Enablement macro:

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    
    <xsl:param name="currentPage"/>
    
    <xsl:variable name="useMacro" select="/macro/macroToCall"/>
    
    <xsl:template match="/">
    
    <xsl:variable name="homeNode" select="$currentPage/ancestor-or-self::Home[@isDoc]"/>
    <xsl:variable name="showRegister" select="$homeNode/useGigya"/>
    
    <xsl:if test="$homeNode/useGigya = 1">
        <xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO macroAlias=&quot;$useMacro&quot; &gt;&lt;/?UMBRACO_MACRO&gt;', $currentPage/@id)" disable-output-escaping="yes" />
    </xsl:if>
    
    </xsl:template>
    

    What am I doing wrong? The macro name I am passing in is there; I was able to see it when I just write the variable name. But the Macro I am trying to "run" within this XSLT isn't showing what it is supposed to; it isn't writing the import of the Javascript.

    Thanks in advance, Garrett

  • Garrett Fisher 341 posts 496 karma points
    Oct 12, 2016 @ 14:41
    Garrett Fisher
    0

    Can anyone teach me how to perhaps do this using Razor logic within the template? If this true/false field from the page in the CMS has a true value then go ahead and write the macro call?

    Thanks, Garrett

Please Sign in or register to post replies

Write your reply to:

Draft