Copied to clipboard

Flag this post as spam?

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


  • Kelsee Ishmael 71 posts 158 karma points
    Mar 28, 2014 @ 22:54
    Kelsee Ishmael
    0

    Archetype Rich Text Editor (RTE) Macro Rendering

    I am using the Archetype package (http://imulus.github.io/Archetype/). It has been working great, I have a data type built that uses the RTE for repeating content. I'm trying to throw macros into this content, but I cannot get the macros to render. I was initially using @Html.Raw() to render the content, but this will not output the macros. Here in the code I'm using in my template so far to render the content:

    @foreach (var fieldset in Model.Content.GetPropertyValue<Archetype>("sectionOneContent").Fieldsets){
        count = Model.Content.GetPropertyValue<Archetype>("sectionOneContent").Fieldsets.Count();
        <div class="col@(count>1?" one-half":"")">@Html.Raw(fieldset.GetValue("content"))</div>
    }

     

    The output I get when using this is rendered html, but not a rendered macro - only the placeholder that is in the RTE. Ex:

    <div class="umb-macro-holder InsertWistiaVideo mceNonEditable umb-macro-mce_0"><!-- <?UMBRACO_MACRO macroAlias="InsertWistiaVideo" wistiaId="plk53ist2i" /> --><ins>Macro alias: <strong>InsertWistiaVideo</strong></ins></div>

     

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Mar 29, 2014 @ 15:04
    Jeavon Leopold
    0

    Only way I currently know how to do this is like this:

     @Html.Raw(umbraco.library.RenderMacroContent(fieldset.GetValue("content"), Model.Content.Id))
    

    Obviously change the p

    I wonder if there is a newer version although it's not marked as obsolete. Seems like something that should be in TemplateUtilities :-)

  • Kelsee Ishmael 71 posts 158 karma points
    Apr 01, 2014 @ 00:34
    Kelsee Ishmael
    0

    I wish that worked :-\, I get the same result and the macro is not rendered.

    Agreed, it would be fantastic to be in TemplateUtilities! :)

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Apr 01, 2014 @ 11:27
    Jeavon Leopold
    1

    Hi Kelsee,

    I've just given this a try and it seems to work without even needing to use RenderMacroContent

    Just like this:

    @foreach (var fieldset in Model.Content.GetPropertyValue<Archetype>("car").Fieldsets)
    {    
        @Html.Raw(fieldset.GetValue("Desc"))
    }
    

    I've tested with v7.0.4 and v7.1.0RC and Archetype v0.5.1, what version are you using?

    Jeavon

  • Kelsee Ishmael 71 posts 158 karma points
    Apr 01, 2014 @ 17:38
    Kelsee Ishmael
    0

    Hi Jeavon,

    Thanks for your reply. I'm using v7.0.4 and rchetype Archetype 0.5.1-alpha.

    I suppose the only thing I can think of is that I upgraded umbraco from versino 7.0.0. Perhaps something got lost?

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Apr 01, 2014 @ 19:04
    Jeavon Leopold
    0

    What type of macro are you trying to render, Usercontrol, Scripting file, Macro Partial View etc....?

  • Kelsee Ishmael 71 posts 158 karma points
    Apr 01, 2014 @ 19:06
    Kelsee Ishmael
    0

    A simple Macro Partial View. I've tried a couple different ones - some with parameters some without.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Apr 01, 2014 @ 19:21
    Jeavon Leopold
    100

    Strange, this is what I have in my Archetype RTE:

    <div class="umb-macro-holder Test mceNonEditable umb-macro-mce_0"><!-- <?UMBRACO_MACRO macroAlias="Test" /> --><ins>
    <p>I am a macro</p>
    </ins></div>
    

    And Razor is like this:

    @inherits UmbracoTemplatePage
    @using Archetype.Umbraco.PropertyConverters;
    @using Archetype.Umbraco.Models;
    @using Archetype.Umbraco.Extensions;
    
    @foreach (var fieldset in Model.Content.GetPropertyValue<Archetype>("car").Fieldsets)
    {    
        @Html.Raw(fieldset.GetValue("Desc"))
    }
    
  • Kelsee Ishmael 71 posts 158 karma points
    Apr 01, 2014 @ 19:42
    Kelsee Ishmael
    0

    So the key is that you need to have "render macro in rich text editor" checked. This works for most of them, but some macros this might cause an issue (I have a wistia embed macro that this doesn't work for).

    Thanks for all the help!

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Apr 01, 2014 @ 20:16
    Jeavon Leopold
    0

    Great it's working! Oddly, I don't have that requirement, seems to work both when checked or not for me....

    Maybe just re-saving the Macro has fixed the issue, have you tried unchecking a working one to see if it still works?

  • Kelsee Ishmael 71 posts 158 karma points
    Apr 01, 2014 @ 20:25
    Kelsee Ishmael
    0

    That's odd, but good to know it's not a problem for you. Perhaps it was the upgrade that made my install act funky. I tried unchecking to see if it works and no go. At least there is a halfway solution!

  • Kelsee Ishmael 71 posts 158 karma points
    Apr 01, 2014 @ 20:26
    Kelsee Ishmael
    0

    That's odd, but good to know it's not a problem for you. Perhaps it was the upgrade that made my install act funky. I tried unchecking to see if it works and no go. At least there is a halfway solution!

  • jeff mayer 122 posts 200 karma points
    Apr 15, 2014 @ 22:58
    jeff mayer
    0

    I would appreciate if someone can chime in on this. I think its related.

    related issue with archetype

  • Kelsee Ishmael 71 posts 158 karma points
    Apr 15, 2014 @ 23:13
    Kelsee Ishmael
    0

    It doesn't really seem realted and I can't say that my issue is fully fixed,.. but I added something to your thread that may help

Please Sign in or register to post replies

Write your reply to:

Draft