I was posting on twitter regarding this, but I have a problem with a macro which is contained in a Rich Text Editor.
I know that I can render macro content within another macro by using one of the library functions (I think it's RenderMacroContent or something?)
I'm using umbraco 4.5.2
The structure of my document types are as follows:
Homepage Text Page Tab Control Tab Tab
Text page has a template which renders the page. In this text page, there's a macro which renders the nested child "Tab" documents, as a series of tabs (with some javascript to switch between them)
As part of the "tab" document type, I want people to be able to edit the contents of the tab, and in this case, insert one of 4 different macros which are calculators (which will be implemented with javascript + XSLT or perhaps a usercontrol - either way I need to wrap in a macro)
The attached image probably shows it best.
When this page renders, the macro contained in the text page "Fitness Calculators" template ("Text Page") iterates over the "Tab" items (in the screenshot, BMI is a tab item) and renders the markup.
It's iterated twice, once for the headings, once for the tab bodies.
As part of that macro, the contents of the RTE is rendered, using <xsl:value-of select="./textContent" disable-output-escaping="yes"/> or similar. (I forget what the actual field name on the document type is)
The resulting markup sent to the browser contains <?UMBRACO_MACRO macroAlias="calculatorbmi" />
I was thinking that maybe some sort of solution using a replace, maybe with a regex, searching for umbraco macros and calling render content for them.. as part of perhaps an XSLT extension might work.
Pass the RTE content to said extension, then this can search for any embedded macros and make sure they're rendered appropriately while still preserving the other RTE markup.
The problem is that there's embedded images and embedded styles (as you can see from the picture above) as well as the embedded macro, so I can't just call RenderMacroContent directly.
Also, I found a problem when my macro name was "calculator-bmi" - this crashes google chrome when you try to insert the macro into the RTE.. but that's an entirely different problem.
I could restructure my document types so the main sub-headings under "Tab" : "Key Note", "Interpretation of results" etc are actually nested document types /documents under tab, but that would only shift the problem down the tree one - I'd still end up with a nested macro inside the RTE for the "tab section" document.
Hope this provides enough detail for someone to help.
It turns out, that most of the time - when you take the time to make a post about the problem you're having.. you solve it < 5 mins later.
It wasn't obvious, but umbraco.library:RenderMacroContent will do what I was suggesting with the regex - I thought it would only handle a single macro definition passed to it.
This means, that if i'm calling the value-of like this:
and ./textContent is from an RTE which contains a macro; calling value-of like this
<xsl:value-of select="umbraco.library:RenderMacroContent(./textContent, $currentPage/@Id)" disable-output-escaping="yes"/> will render the contents of the RTE plus resolve any embedded macros to their real HTML markup.
nested macros + RTE
Hi Guys
I was posting on twitter regarding this, but I have a problem with a macro which is contained in a Rich Text Editor.
I know that I can render macro content within another macro by using one of the library functions (I think it's RenderMacroContent or something?)
I'm using umbraco 4.5.2
The structure of my document types are as follows:
Homepage
Text Page
Tab Control
Tab
Tab
Text page has a template which renders the page. In this text page, there's a macro which renders the nested child "Tab" documents, as a series of tabs (with some javascript to switch between them)
As part of the "tab" document type, I want people to be able to edit the contents of the tab, and in this case, insert one of 4 different macros which are calculators (which will be implemented with javascript + XSLT or perhaps a usercontrol - either way I need to wrap in a macro)
The attached image probably shows it best.
When this page renders, the macro contained in the text page "Fitness Calculators" template ("Text Page") iterates over the "Tab" items (in the screenshot, BMI is a tab item) and renders the markup.
It's iterated twice, once for the headings, once for the tab bodies.
As part of that macro, the contents of the RTE is rendered, using <xsl:value-of select="./textContent" disable-output-escaping="yes"/> or similar. (I forget what the actual field name on the document type is)
The resulting markup sent to the browser contains <?UMBRACO_MACRO macroAlias="calculatorbmi" />
Here's the actual page (you can use umbShowDebugTrace if required)
Please note this is a development site, so it may not stay up permanently.
http://leeannewann.ineedcoffee.co.nz/fitness-calculators.aspx
I was thinking that maybe some sort of solution using a replace, maybe with a regex, searching for umbraco macros and calling render content for them.. as part of perhaps an XSLT extension might work.
Pass the RTE content to said extension, then this can search for any embedded macros and make sure they're rendered appropriately while still preserving the other RTE markup.
The problem is that there's embedded images and embedded styles (as you can see from the picture above) as well as the embedded macro, so I can't just call RenderMacroContent directly.
Also, I found a problem when my macro name was "calculator-bmi" - this crashes google chrome when you try to insert the macro into the RTE.. but that's an entirely different problem.
This post is similar: http://our.umbraco.org/forum/developers/extending-umbraco/4713-Run-Macro-inside-RTE-that-is-called-from-another-macro however not quite what i'm after.
I could restructure my document types so the main sub-headings under "Tab" : "Key Note", "Interpretation of results" etc are actually nested document types /documents under tab, but that would only shift the problem down the tree one - I'd still end up with a nested macro inside the RTE for the "tab section" document.
Hope this provides enough detail for someone to help.
Gareth
It turns out, that most of the time - when you take the time to make a post about the problem you're having.. you solve it < 5 mins later.
It wasn't obvious, but umbraco.library:RenderMacroContent will do what I was suggesting with the regex - I thought it would only handle a single macro definition passed to it.
This means, that if i'm calling the value-of like this:
<xsl:value-of select="./textContent" disable-output-escaping="yes"/>
and ./textContent is from an RTE which contains a macro; calling value-of like this
<xsl:value-of select="umbraco.library:RenderMacroContent(./textContent, $currentPage/@Id)" disable-output-escaping="yes"/> will render the contents of the RTE plus resolve any embedded macros to their real HTML markup.
Problem solved
Sorry for any hassles caused ;)
Good to see you solved it! :)
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.