I started with a clean xslt and had it create the macro for me. Now when I insert this into the editor, I expect to see "Hello" in red in the editor and on the page when rendered. I can't get it to show anything in either place. I've checked both box's to use in editor and render content. I've actually written a number of xslt that have worked great when called from my template, but have yet to get one to work in the editor. What's my problem? Please help! Thanks!
I would recommend from experience not to insert macros into text fields, as at least in older versions of Umbraco (pre version 4) the calls would sometimes get corrupted and stop working but a bigger issue is someone accidentally deleting the macro call while updating the page content. You can pass values from the text and settings from the page through the macro call to the template.
I think I figured out what the problem is on this. The macro is not rendering because the content is nested in another parent macro/xslt call. So the parent macro is trying to render content that also has a nested macro and I'm guessing this is not possible. Can anyone confirm?
If you use xslt to render your content-field, then you can use one of the build in umbraco extensions. If you have a richtext editor with an alias of "content", you can use the below code to render the content including the inserted macro:
I remember having managed to get macros in editor fields that were themselves rendered from a macro to work, which involved a recursive template — something along the following steps:
Render all content before the (1st) macro
Extract the macro markup and pass that on to the library function RenderMacroContent()
Do it again with the remaining content, checking for more macros...
I'll try to find the actual code if anyone's interested...
Kim, your code worked. Thanks allot! It will be helpful to have this as an option and worked great for my specific need.
Chriztian - Thanks for you info as well. Looks like a good approach if you have multiple nested macros (more then one level deep). Thankfully that is not the case for me right now but I will keep that idea in my back pocket.
Need help with very simple xslt to use in editor
I'm starting very simple here, I've created a xslt that does this:
<xsl:template match="/"> <!-- start writing XSLT --> <span style="color: red"> Hello </span> </xsl:template>
I started with a clean xslt and had it create the macro for me. Now when I insert this into the editor, I expect to see "Hello" in red in the editor and on the page when rendered. I can't get it to show anything in either place. I've checked both box's to use in editor and render content. I've actually written a number of xslt that have worked great when called from my template, but have yet to get one to work in the editor. What's my problem? Please help! Thanks!
I would recommend from experience not to insert macros into text fields, as at least in older versions of Umbraco (pre version 4) the calls would sometimes get corrupted and stop working but a bigger issue is someone accidentally deleting the macro call while updating the page content. You can pass values from the text and settings from the page through the macro call to the template.
I think I figured out what the problem is on this. The macro is not rendering because the content is nested in another parent macro/xslt call. So the parent macro is trying to render content that also has a nested macro and I'm guessing this is not possible. Can anyone confirm?
Yeah you are right r_lamb.
If you use xslt to render your content-field, then you can use one of the build in umbraco extensions. If you have a richtext editor with an alias of "content", you can use the below code to render the content including the inserted macro:
Hope this fixes your problem :)
/Kim
I remember having managed to get macros in editor fields that were themselves rendered from a macro to work, which involved a recursive template — something along the following steps:
I'll try to find the actual code if anyone's interested...
/Chriztian
Kim, your code worked. Thanks allot! It will be helpful to have this as an option and worked great for my specific need.
Chriztian - Thanks for you info as well. Looks like a good approach if you have multiple nested macros (more then one level deep). Thankfully that is not the case for me right now but I will keep that idea in my back pocket.
You are welcome :)
Remember to mark this post as answered ;)
is working on a reply...