Copied to clipboard

Flag this post as spam?

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


  • UmbracoNovice 15 posts 50 karma points
    Nov 02, 2013 @ 21:15
    UmbracoNovice
    0

    Macro renders correctly in template but not in WYSIWYG editor

    Hello

    Using Umbraco v6.1.6 I've written a MVC Partial View which is in the Views/MacroPartials folder I created the cshtml file via the Partial View Macro Files option and its visible there. I created a Macro for it as I need it available in the WYSIWYG Content editor.  Its displays a google map and applies some markers.

    When I apply it to a template it previews fine and all works. However when I reference the Macro directly in the Content editor and not via a Template it doesn't work and renders no markup. I've checked the Use In Editor and Render content in editor checkboxes in the Macro.

    Am I doing something wrong with the setup? Is there a better way?

    Thanks for looking 

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Nov 04, 2013 @ 14:59
    Lee Kelleher
    0

    Hi,

    Unfortunately the rendering of Macros within the WYSIWYG editor (TinyMCE) isn't great.

    There are a few things to keep in mind with it, e.g. what type of HTML is being rendered - anything beyond basic formatting may have adverse side-effects, like <script>, <embed> or <iframe> tags.

    It all depends on what you are wanting to achieve (for the content editor).

    Cheers,
    - Lee

  • UmbracoNovice 15 posts 50 karma points
    Nov 04, 2013 @ 20:45
    UmbracoNovice
    0

    Hi Lee

    Thanks for taking the time to reply.

    Is there an alternative approach to take? I have a cshtml file which is rendering a google map and I want it to be available in various content pages.

    Thanks

     

     

     

     

     

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Nov 05, 2013 @ 11:07
    Lee Kelleher
    0

    It is tricky to strike a balance between a functional macro and having that render nicely within the rich-text editor (TinyMCE).

    One approach that I have taken is to render different markup for the rich-text editor.

    When a macro is inserted into the rich-text it makes a call to a core page called macroResultWrapper.aspx - this is responsible for rendering the macro for the rich-text editor. To do this a querystring parameter called umb_macroAlias is passed to it with the alias name of the macro.

    Then you can take advantage of the umb_macroAlias querystring parameter within your own macro. So instead of rendering the full Google Map JavaScript version you could render a light-weight version: e.g. a static image.

    (Take a look at Google Maps Image APIs documentation)

    Quick example of the logic:

    @if(!string.IsNullOrEmpty(Request.QueryString["umb_macroAlias"]))
    {
        // render the rich-text editor friendly version: e.g. static image map
    }
    else
    {
        // render the original Google Map
    }
    

    Good luck!

    Cheers,
    - Lee

Please Sign in or register to post replies

Write your reply to:

Draft