I have one macro which shows a sidebar and inside this macro i want to place another marcro with some properties. This macro should be use from TinyMCE
Everytime i place something in this macro it is not rendered in the frontend
ok but i need the propertie window from the second macro in my content editor - how can i achieve this
If i place it directly in the first xslt script i can not use it with properties out of my richtext editor.
So my first macro generates a sidebar. The second macro is to show a button with properties (cssclass, text, link) this should be placed inside the richtext.
In the editor all looks good and the content is rendered but on the webseite i get only
second xslt script is only for displaying a button with some macro properties "name", "link" and "css class".
This should be shown inside the <div> of xslt script 1.
But i have to place it in the content Richtext editor field of "sidebarContent" so i am prompted for the properties, name, cssclass and link.
So what should it do:
The user/marketing people will place an order now button and link it to a site. Select a css class and name it with a dictonary item inside the sidbear (with Richtext editor)
So sidebar is working correct but the button is not displayed :-(
OK, instead of trying to call a macro from another macro, what you should do is, in the 'outer' macro, create a reference to the 'inner' macro using an <xsl:import>
e.g.
<xsl:import href="/inner-macro.xsl"/>
Once you have this, you can use
<xsl:call-template name="templateName"/> and call any templates in your inner macro from your outer macro
but the value / macro property is only known by the inner template. So i think the outer template will not know $valueToPass because it is a value of the inner xslt script
using this method, calling the inner xslt with <xsl:import> method means that you are calling the inner xslt straight through xslt, it has nothing to do with umbraco parameters
Use Macro in Macro
hello,
how can i use a macro inside another macro?
I have one macro which shows a sidebar and inside this macro i want to place another marcro with some properties. This macro should be use from TinyMCE
Everytime i place something in this macro it is not rendered in the frontend
Is there any problem with using macros in macros?
If yes how can i solve this?
Thanks
it displays
<?UMBRACO_MACRO in the source code for this macro
If you're using xslt's you can use the umbraco.library:RenderMacro function. * This won't work for usercontrols
so where i have to use this? inside the first xslt macro?
Yep, in the first macro, use <xsl:value-of select="umbraco.library:RenderMacro(innerMacroName)"/>
Although, the better way to do this would be:
In the first xslt macro, make a reference to the second xslt macro. Once you've done that, you can call any template in the second macro
ok but i need the propertie window from the second macro in my content editor - how can i achieve this
If i place it directly in the first xslt script i can not use it with properties out of my richtext editor.
So my first macro generates a sidebar. The second macro is to show a button with properties (cssclass, text, link) this should be placed inside the richtext.
In the editor all looks good and the content is rendered but on the webseite i get only
<?UMBRACO_MACRO in the source code forthis macro
Can you please paste in the code from the 2 xslt files so I can get a clear look at what you're trying to do?
so first xslt script is:
<xsl:if test="$currentPage/sidebarContent != '' ">
<div class="content">
<xsl:value-of select="$currentPage/sidebarContent" disable-output-escaping="yes"/>
</div>
</xsl:if>
second xslt script is only for displaying a button with some macro properties "name", "link" and "css class".
This should be shown inside the <div> of xslt script 1.
But i have to place it in the content Richtext editor field of "sidebarContent" so i am prompted for the properties, name, cssclass and link.
So what should it do:
The user/marketing people will place an order now button and link it to a site. Select a css class and name it with a dictonary item inside the sidbear (with Richtext editor)
So sidebar is working correct but the button is not displayed :-(
Thanks
Might be a little late to this thread...
but did you see....
http://our.umbraco.org/wiki/reference/umbracolibrary/rendermacrocontent
I tend to use it like this...
makes it a little easier to read. :-)
and then in the template match
Hi Mike,
Sorry I dont understand - i am using Umbraco 4.7 and not an old one. So I think i have to use the new type of writing macros or?
<umbraco:Macro Alias="Button" runat="server"></umbraco:Macro>
But if i do so it is not rendered in the frontend -
I think there is a problem of rendering a macro inside another macro. THis seems to be an umbraco error or?
Thanks
Are you trying to render a usercontrol macro inside an xslt macro? If so, you can't do that
No it is not a usercontrol.
Both are xslt macros
I want to render a xslt macro inside my other xslt macro - but it is not rendered in the frontend
OK, instead of trying to call a macro from another macro, what you should do is, in the 'outer' macro, create a reference to the 'inner' macro using an <xsl:import>
e.g.
<xsl:import href="/inner-macro.xsl"/>
Once you have this, you can use
<xsl:call-template name="templateName"/> and call any templates in your inner macro from your outer macro
hey, if i do so
i can not get this working in the inner xslt:
<xsl:variable name="text" select="/macro/text"/>
<xsl:variable name="class" select="/macro/class"/>
<xsl:template name="showButton">
<xsl:value-of select="$text"/>
</xsl:template>
It looks like it is not getting macro parameters
Fixed texts are working
You will need to pass the parameters explicity
So, in the template in the inner macro, create template paramaters, then pass the parameters
e.g.
<xsl:template name="showButton">
<xsl:with-param name="css" select="$css"/>
<!-- Do this for all parameters -->
</xsl:template>
'xsl:with-param' cannot be a child of the 'xsl:template' element.
if youy read the wiki, you'll see that even for u4.7 you use the old method in order to use the render macro content...
I can confirm that I'm using the exact same method in 4.5.2 and 4.7 and 4.7.1 nightly and it works in all instances :-)
i now trying the xsl:import method but paramaters are not working
if you read the wiki, you'll see that even for u4.7 you use the old method in order to use the render macro content...
I can confirm that I'm using the exact same method as I have above in 4.5.2 and 4.7 and 4.7.1 nightly and it works in all instances :-)
I think the xsl:import method is a better and easier solution but it looks likeI can not use parameters in the inner xslt script.
you can use parameters in the inner xslt script, I've done it quite a few times
You do it like so:
<xsl:template name="showButton">
<xsl:with-param name="css" select="$css"/>
</xsl:template>
Could you post your xslts so I can have a look?
if i try this i get
'xsl:with-param' cannot be a child of the 'xsl:template' element.
Oh, I see.
On the inner template, you do this
<xsl:template name="innerMacroTemplate">
<xsl:param name="myParam"/>
</xsl:template>
Then when you call the template, you do this
<xsl:call-template name="innerMacroTemplate">
<xsl:with-param name="myParam" select"$valueToPass"/>
</xsl:call-template>
but the value / macro property is only known by the inner template. So i think the outer template will not know $valueToPass because it is a value of the inner xslt script
OK, if the inner property already knows the value, then it doesn't need to be passed by the outer template
yes but it does not work
here is my outer xslt:
<xsl:call-template name="showButton"></xsl:call-template>
And this is the inner xslt
<xsl:variable name="text" select="/macro/text"/>
<xsl:variable name="class" select="/macro/class"/>
<xsl:template name="showButton">
<h3>
<xsl:value-of select="$text"/>
</h3>
</xsl:template>
But text is not displayed.
OK, you need to pass the value from the outer macro to the inner macro like so:
Outer Macro
<xsl:param name="text" select="/macro/text"/>
<xsl:param name="class" select="/macro/class"/>
<xsl:call-template name="showButton">
<xsl:with-param name="text" select="$text"/>
<xsl:with-param name="class" select="$class"/>
</xsl:call-template>
Inner Macro
<xsl:template name="showButton">
<xsl:param name="text"/>
<xsl:param name="class"/>
<h3>
<xsl:value-of select="$text"/>
</h3>
</xsl:template>
But "/macro/text/" and "/macro/class" are properties of the inner xslt macro and not known by the outer xslt script I think.
Will outer xslt will know the macro properties of the innner xslt automatically?
Make them macro parameters of the outer xslt
I should clarify;
using this method, calling the inner xslt with <xsl:import> method means that you are calling the inner xslt straight through xslt, it has nothing to do with umbraco parameters
Hi Euan,
I could not get it working with your solution because the macro properties depends on the inner xslt script.
I tried Mikes solution and this works
Thanks a lot for your help Euan and Mike
is working on a reply...