Here is a challenge we're facing. Any ideas are welcome!
We have built a custom photo gallery for one of our customers. It uses the common concept of a Media Picker choosing a media library folder and then XSLT to display all the images for the gallery. That works fine.
Then we found out that we needed to have "content" (think bodyText) regarding each image in the gallery, so (a bit reluctantly) we added a Rich Text Editor (RTE) to the image media type. We're pulling in that "imageContent" item with XSLT. That seemed to works fine.
Next we inserted a macro into that RTE and now we have a problem!
The macro renders fine in the RTE as you can see above. Unfortunately, when the XSLT pulls the imageContent on the public side, the macro is just getting sent through as "markup" and is not being evaluated.
<p>Location: Green Bay, WI<br /> Project: Test Track<br /> Product(s) Used:</p>
<?UMBRACO_MACRO linktext="Mondo Super X Performance" downloadfilemediaid="2201" macroAlias="myLink" />
Now in the past I've used "RenderTemplate" on "bodyText" to get past this type of issue but my content normally is coming from the content area, not the media library. RenderTemplate does not work passing in a Media node (not surprisingly) -- yes, i actually tried it.
How can I take a piece of content and get umbraco to render the macros contained within?
Unfortunately, we are so far down the line with this approach and now it looks like a dead end. Any help is greatly appreciated!
I am assuming that a macro is writing out the images? If so then you are using a macro to render out rich text edit field which has macro in it. That does not even work in content section so your error i think is not that you have rte in media item but the media item is writen out by macro and media item has macro in it as well hence it renders out literal.
Yes, your point is correct. We have a macro writing out the images for the gallery and then that macro pulls in the "imageContent" which also contains a macro.
I would respectfully challenge the "does not even work in content section", as the following XSLT code can be used by a macro embedded in RTE content to pull content that also contains a macro and the "rendering" forces the second macro to be evaluated. We use this for a "GetContent" macro functionality which does not restrict the user from inserting macros in their reusable content. I guess I was hoping for some kind of API "renderer" that could just take a content block (in this case from media) and force it to evaluate the macros, etc.
It's amazing how writing clarifies thinking sometimes. I did a search for "render" and found this great article which got me on the right track. Forcing the resulting content through RenderMacroContent() resolved my problem.
Oh, that's really good to know. Thx! I have to work a little more that project later today. Perhaps I'll give it a try and see what the results are with media area.
RTE on media item with macros
Here is a challenge we're facing. Any ideas are welcome!
We have built a custom photo gallery for one of our customers. It uses the common concept of a Media Picker choosing a media library folder and then XSLT to display all the images for the gallery. That works fine.
Then we found out that we needed to have "content" (think bodyText) regarding each image in the gallery, so (a bit reluctantly) we added a Rich Text Editor (RTE) to the image media type. We're pulling in that "imageContent" item with XSLT. That seemed to works fine.
My macro XSLT to get the imageContent looks like:
Next we inserted a macro into that RTE and now we have a problem!
The macro renders fine in the RTE as you can see above. Unfortunately, when the XSLT pulls the imageContent on the public side, the macro is just getting sent through as "markup" and is not being evaluated.
Now in the past I've used "RenderTemplate" on "bodyText" to get past this type of issue but my content normally is coming from the content area, not the media library. RenderTemplate does not work passing in a Media node (not surprisingly) -- yes, i actually tried it.
How can I take a piece of content and get umbraco to render the macros contained within?
Unfortunately, we are so far down the line with this approach and now it looks like a dead end. Any help is greatly appreciated!
James,
I am assuming that a macro is writing out the images? If so then you are using a macro to render out rich text edit field which has macro in it. That does not even work in content section so your error i think is not that you have rte in media item but the media item is writen out by macro and media item has macro in it as well hence it renders out literal.
regards
Ismail
Yes, your point is correct. We have a macro writing out the images for the gallery and then that macro pulls in the "imageContent" which also contains a macro.
I would respectfully challenge the "does not even work in content section", as the following XSLT code can be used by a macro embedded in RTE content to pull content that also contains a macro and the "rendering" forces the second macro to be evaluated. We use this for a "GetContent" macro functionality which does not restrict the user from inserting macros in their reusable content. I guess I was hoping for some kind of API "renderer" that could just take a content block (in this case from media) and force it to evaluate the macros, etc.
Hey, found a solution:
It's amazing how writing clarifies thinking sometimes. I did a search for "render" and found this great article which got me on the right track. Forcing the resulting content through RenderMacroContent() resolved my problem.
Hi James
I know you found your solution, but in the future I think you can use this as well:
I haven't tried it with an editor from the media library, but it should be the same principle I think.
The advantage of the Item-extension is that this will render the content through your XSLT, but the edit in canvas will still work.
Well, just wanted to let you know about it if you are facing some similiar challenges in the future. Have a nice day :)
/Kim A
Oh, that's really good to know. Thx! I have to work a little more that project later today. Perhaps I'll give it a try and see what the results are with media area.
is working on a reply...