<!-- start writing XSLT --> <!-- determine which banner to show --> <xsl:choose> <xsl:whentest="$domainName = 'bd.admiral.dk'"> <!-- code for banner here --> </xsl:when> <xsl:whentest="$domainName = 'dk.admiral.dk'"> <!-- code for alternative banner goes here --> </xsl:when> <xsl:otherwise> <!-- code for default banner goes here --> <!--tag it here-->
I don't fully understand what you want to do - but if you're trying to render the AdmiralLogControl macro inside of the XSLT macro, you need to know that you can only render another XSLT macro this way. It's just not possible to render a UserControl macro from an XSLT macro.
But this beoing Umbraco, there's always a way to get what you want, we just need to know a little more...
It's just not possible to render a UserControl macro from an XSLT macro.
Critzian, thx, that's a usefull tip - personally I've never been aware of this limitation before, perhaps because I started with umbraco from 4.7 and hardly ever used webcontrol macros at all (I strongly prefer razor).
I'm wondering is there the same limitation for razor macros?
Maybe you could put your macro in your template file, in an invisible div. And then in the "otherwise" clause of your xslt, you write the javascript/jquery code that makes the div visible.
Max, I think you could use a control macro as your "wrapping" macro instead of an xslt one. There shouldn't be a problem with using control macros inside another control macro via <umbraco:Macro> control. You could place several <umbraco:Macro> controls inside an <asp:MultiView> control or add a required one programmatically to some placeholder or like that - anything that you can do with usual asp.net controls.
As I understand I also suppose that custom rendering of a user control macro from an xslt one actually should work - the thing that won't work is processing a later postback by this control if there's any afterwards.
Good to hear! Can you maybe mark one of the post mentioning RenderMacroContent as the solution to your issue? This will help other people with the same issue to spot the solution. Thanks!
This isn't working for me. Does RenderMacroContent() work in Umbraco 7? My macro output is:
<Macro: (,)>
Can anyone help? I have a containing XSLT macro which contains logic on whether or not to display a certain other macro; takes the other macro as a passed-in paramter and that string is coming in fine but the macro output is not displaying/working.
The way you're sending the string to the function, actually makes it try to render a macro called $useMacro - you need to put the contents of the variable into the string, like this:
calling a macro in XSLT
Hi i have a xslt file which will call an existing macro within umbraco
i need some suggestion on how to tag the macros in xslt
this is my existing macro
<umbraco:Macro Alias="AdmiralLogControl" runat="server">
here isn my new xslt :
<xsl:variable name="domainName">
<xsl:value-of select="umbraco.library:RequestServerVariables('HTTP_HOST')" />
</xsl:variable>
<xsl:template match="/">
<!-- start writing XSLT -->
<!-- determine which banner to show -->
<xsl:choose>
<xsl:when test="$domainName = 'bd.admiral.dk'">
<!-- code for banner here -->
</xsl:when>
<xsl:when test="$domainName = 'dk.admiral.dk'">
<!-- code for alternative banner goes here -->
</xsl:when>
<xsl:otherwise>
<!-- code for default banner goes here -->
<!--tag it here-->
</xsl:otherwise>
</xsl:choose>
Hi Max,
I don't fully understand what you want to do - but if you're trying to render the AdmiralLogControl macro inside of the XSLT macro, you need to know that you can only render another XSLT macro this way. It's just not possible to render a UserControl macro from an XSLT macro.
But this beoing Umbraco, there's always a way to get what you want, we just need to know a little more...
/Chriztian
how about rendering the macro in xslt method any code examples would be useful
Hi Max,
In order to do this you will need to use the RenderMacroContent library method. You can find more info on http://our.umbraco.org/wiki/reference/umbracolibrary/rendermacrocontent
Cheers,
Michael.
Hi Max,
To render a macro form XSLT, you call the RenderMacroContent() extension in umbraco.library
/Chriztian
It's just not possible to render a UserControl macro from an XSLT macro.
Critzian, thx, that's a usefull tip - personally I've never been aware of this limitation before, perhaps because I started with umbraco from 4.7 and hardly ever used webcontrol macros at all (I strongly prefer razor).
I'm wondering is there the same limitation for razor macros?
it does not seem to work since its .net user control any other options ??
Hi Max,
Maybe you could put your macro in your template file, in an invisible div. And then in the "otherwise" clause of your xslt, you write the javascript/jquery code that makes the div visible.
Cheers,
Michael.
its done here is the code
<xsl:variable name="domainName">
<xsl:value-of select="umbraco.library:RequestServerVariables('HTTP_HOST')" />
</xsl:variable>
<xsl:template match="/">
<!-- start writing XSLT -->
<!-- determine which banner to show -->
<xsl:choose>
<xsl:when test="$domainName = 'bd.admiral.dk'">
<!-- code for banner here -->
<xsl:value-of select="umbraco.library:RenderMacroContent('<?UMBRACO_MACRO macroAlias="AdmiralLogBDControl" ></?UMBRACO_MACRO>', $currentPage/@id)" disable-output-escaping="yes" />
</xsl:when>
<xsl:when test="$domainName = 'dk.admiral.dk'">
<!-- code for alternative banner goes here -->
<xsl:value-of select="umbraco.library:RenderMacroContent('<?UMBRACO_MACRO macroAlias="AdmiralLogDKControl" ></?UMBRACO_MACRO>', $currentPage/@id)" disable-output-escaping="yes" />
</xsl:when>
<xsl:otherwise>
<!-- code for default banner goes here -->
<xsl:value-of select="umbraco.library:RenderMacroContent('<?UMBRACO_MACRO macroAlias="AdmiralLogControl" ></?UMBRACO_MACRO>', $currentPage/@id)" disable-output-escaping="yes" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Max, I think you could use a control macro as your "wrapping" macro instead of an xslt one. There shouldn't be a problem with using control macros inside another control macro via <umbraco:Macro> control. You could place several <umbraco:Macro> controls inside an <asp:MultiView> control or add a required one programmatically to some placeholder or like that - anything that you can do with usual asp.net controls.
Max,
Does the XSLT you posted actually work then? With .Net controls?
Cheers,
Michael.
As I understand I also suppose that custom rendering of a user control macro from an xslt one actually should work - the thing that won't work is processing a later postback by this control if there's any afterwards.
that script consist of 3 .net user controls it worked perfectly fine for me ..
thank you
Hi Max,
Good to hear! Can you maybe mark one of the post mentioning RenderMacroContent as the solution to your issue? This will help other people with the same issue to spot the solution. Thanks!
Cheers,
Michael.
This isn't working for me. Does RenderMacroContent() work in Umbraco 7? My macro output is:
Can anyone help? I have a containing XSLT macro which contains logic on whether or not to display a certain other macro; takes the other macro as a passed-in paramter and that string is coming in fine but the macro output is not displaying/working.
Here is the code from the containing XSLT macro:
Thanks,
Garrett
Hi Garrett,
The way you're sending the string to the function, actually makes it try to render a macro called $useMacro - you need to put the contents of the variable into the string, like this:
Hope that helps,
/Chriztian
That does help..... and WORKS! Chriztian -- you've done it again: you've saved my ass. THANK YOU!!!
//Garrett
is working on a reply...