Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • James Hildeman 92 posts 88 karma points
    Aug 11, 2010 @ 16:06
    James Hildeman
    0

    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:

    <xsl:value-of select="./data[@alias='imageContent']" disable-output-escaping="yes"/>

    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!
     

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Aug 11, 2010 @ 17:47
    Ismail Mayat
    0

    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

  • James Hildeman 92 posts 88 karma points
    Aug 11, 2010 @ 19:28
    James Hildeman
    1

    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.

          <xsl:value-of select="umbraco.library:RenderTemplate($myNodeId, $myTemplateId)" disable-output-escaping="yes"/>
  • James Hildeman 92 posts 88 karma points
    Aug 11, 2010 @ 20:01
    James Hildeman
    0

    Hey, found a solution:

          <xsl:value-of select="umbraco.library:RenderMacroContent(./data[@alias='imageContent'], $currentPage/@id)" disable-output-escaping="yes"/>

    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.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Aug 12, 2010 @ 08:47
    Kim Andersen
    0

    Hi James

    I know you found your solution, but in the future I think you can use this as well:

    <xsl:value-of select="umbraco.library:Item($currentPage/@id,'imageContent')" />

    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

  • James Hildeman 92 posts 88 karma points
    Aug 12, 2010 @ 15:20
    James Hildeman
    0

    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.

     

Please Sign in or register to post replies

Write your reply to:

Draft