Copied to clipboard

Flag this post as spam?

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


  • Dan Sørensen 102 posts 327 karma points
    Feb 19, 2015 @ 17:44
    Dan Sørensen
    0

    macro in rte only show (Macro alias: AliasName)

    Hi I have had problems when i see my site the macro I have inserted some times only output "Macro alias: AliasName" And if I make changes to the macro code it doesn't change on page then I have to delete the macro in the rte and insert it agian.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 19, 2015 @ 18:01
    Jan Skovgaard
    0

    Hi Dan

    Do you have some caching enabled, which could be the cause? Is the macro mapped correctly to the view file?

    /Jan

  • Dan Sørensen 102 posts 327 karma points
    Feb 20, 2015 @ 09:39
    Dan Sørensen
    0

    Hi Jan I have no caching enabled and yes the macro is mapped correctly I can even use the macro in the grid elsewhere and it works fine it only when its in the rte in the grid it have this behaviour. Its like its not rendering the macro when its in the rte.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Feb 20, 2015 @ 09:45
    Dave Woestenborghs
    0

    Hi Dan,

    Have you checked the checkboxes on the macro definition called :

    Use in Rich Text Editor

    Render in Rich Text Editor

    Dave

  • Dan Sørensen 102 posts 327 karma points
    Feb 20, 2015 @ 09:54
    Dan Sørensen
    0

    I deleted the macro from the editor inserted it agian and now I cant get it to do it agian ?... Last I did this nothing happend. if this happend to the editor/customer of the site I can't just rely on them deleting the macro and hoping it will not do it again, I have had many of this small thinks with umbraco 7.. Im at this point that every time i save a node im hoping nothing will fuck up, maybe its because I started with umbraco 7.0.0 I would say it getting better but it still have alot of work to be done in my opinion.

  • Dan Sørensen 102 posts 327 karma points
    Feb 20, 2015 @ 09:57
    Dan Sørensen
    1

    Hi Dave I have tried render in Rich Text Editor and that worked fine it was just when I saw it on the site it didn't render the macro. Umbraco sometimes have its own life :P

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 20, 2015 @ 10:19
    Jan Skovgaard
    0

    Hi Dan

    Hmm, weird - Think it may be the cache not being updated properly when the client deletes the macro.

    Could you try to setup a test-page where you re-create the issue where it just shows the macro message and then try right clicking the "CONTENT" node and then choose "Repulish entire site" - Does it then disappear? And does it then work if you insert the macro you just removed again?

    If so then there at least is an easier workaround - And then I think it should be reported as a bug on the issue tracker since Umbraco should not do this. It should of course not happen and Umbraco should not have it's own life. It should just work :)

    /Jan

  • Dan Sørensen 102 posts 327 karma points
    Feb 23, 2015 @ 13:04
    Dan Sørensen
    0

    Just made a new page made the macro in the rte inside the grid system and agian it will not render the macro and it make no difference if i Repulish entire site.

    enter image description hereenter image description here

    I went in to the macro and selected the render file again and save, I don't think this changed anything, but after this I just inserted two more macros under the first one, on the test page and know there was nothing with the two new ones ?

    so all I make after the first one works fine? then I wrote in the first rte where the one that didn't work was, then after I saved it worked ?

    This is very confusing as its like it only get rendered if you have more than one first time you save and after that it doesn't matter ?

  • Dan Sørensen 102 posts 327 karma points
    Feb 23, 2015 @ 13:45
    Dan Sørensen
    0

    Cant really figure out the pattern for when it work and when it doesn't work, but for me I can get it to work with making a line break under the macro and it will make it work ?

    This must be a bug with the macro if you insert it in the rte in the grid

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 24, 2015 @ 17:16
    Jan Skovgaard
    0

    Hi Dan

    Yeah that does not sound right - Perhaps it's a good idea to report a bug on the issue tracker at http://issues.umbraco.org/issues

    /Jan

  • Tove 15 posts 35 karma points
    May 15, 2015 @ 16:50
    Tove
    0

    Hi Dan Did you get this solved? I have the same problem (being able to render macro directly into template but not via RTE)

    Best regards /Tove

  • Brad Ford 34 posts 75 karma points
    Aug 11, 2015 @ 22:53
    Brad Ford
    0

    I have the same problem.. I just did the surface control tutorial on Umbraco TV. The Contact form created there works fine in a page by itself. But If I put it in a grid it fails.

    enter image description here

    Yet it looks perfect in the back office.

    enter image description here

    So next I took the advice above and added a carriage return under the macro. Absurd that this should make any difference, but it did.

    enter image description here

    Almost a contact form. Have a look what Firebug reports behind this.

    enter image description here

    There is suppose to be inputs between those Divs. Umbraco has decided they are not important. :)

    Joking aside, what is going on here?

  • Tommi Gustafsson 12 posts 144 karma points
    Jan 13, 2016 @ 11:03
    Tommi Gustafsson
    0

    So next I took the advice above and added a carriage return under the macro

    This solved my problem as well. There needs to be a carriage return under the macro or it does not work. This is in Umbraco 7.3.4.

    Thanks for the Help!

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Aug 12, 2015 @ 07:22
    Dave Woestenborghs
    0

    How do you render the text field in your template ?

    Dave

  • Brad Ford 34 posts 75 karma points
    Aug 13, 2015 @ 00:48
    Brad Ford
    0

    Some further info

    That grid cell is set to allow an RTE and that RTE is set to allow setting a macro.

    enter image description here

    As you can see, the macro appears in the backoffice. Just not on the site.

  • Brad Ford 34 posts 75 karma points
    Aug 13, 2015 @ 00:38
    Brad Ford
    0

    Dave

    I don't 'render the text field'. The grid handles that. I just put the grid in the template like this.

    @CurrentPage.GetGridHtml("sitePage", "fanoe")
    
  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Aug 13, 2015 @ 06:43
    Dave Woestenborghs
    0

    I know there is a macro grid editor available for the grid. Can you try this and see if your macro renders if you use that editor ?

    If it does it can be a issue with RTE in the grid.

    Dave

  • Dennis Öhman 32 posts 177 karma points c-trib
    Aug 13, 2015 @ 07:11
    Dennis Öhman
    0

    Yes, RTE doesn't render macros, it has been reported and is due in 7.3. Whether it will be resolved or not I don't know. :)

    http://issues.umbraco.org/issue/U4-6206

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Aug 13, 2015 @ 07:40
    Dave Woestenborghs
    0

    So use the macro grid editor is the only option for now.

    Dave

  • Bendik Engebretsen 105 posts 202 karma points
    Aug 20, 2015 @ 08:08
    Bendik Engebretsen
    0

    I have the same problem. Followed the video series on Surface Controllers, but it seems not everything works the same way in the latest version of Umbraco.

    In the videos, the macro is inserted in the RTE on a normal text page, not a grid page, which is the standard of the new Fanoe starter kit (and for a good reason!) But, when you enable macros in the Grid TextPage editor, the macros will only render in the RTE, not on the frontend.

    I see a "macro grid editor" is mentioned, but I can't find it, any clues?

  • Dennis Öhman 32 posts 177 karma points c-trib
    Aug 24, 2015 @ 15:03
    Dennis Öhman
    0

    Hi,

    They changed issue U4-6206 to be resolved in 7.3.1

    So for the moment I made this simple/ugly extension to UmbracoHelper and as a static method, until they add a better solution. :)

    public static class MacroUtilities
    {
        private static readonly Regex marcoFormat = new Regex(@"(<\?UMBRACO_MACRO (?:.+?)?macroAlias=[""']([^""\'\n\r]+?)[""'].+?)(?:/>|>.*?</\?UMBRACO_MACRO>)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
    
        public static string RenderContentMacro(string content)
        {
            if (UmbracoContext.Current == null)
                return content;
    
    
            return RenderContentMacro(new UmbracoHelper(UmbracoContext.Current), content);
        }
    
    
        public static string RenderContentMacro(this UmbracoHelper UmbracoHelper, string content)
        {
            if (string.IsNullOrWhiteSpace(content))
                return string.Empty;
    
            if (content.IndexOf("UMBRACO_MACRO", StringComparison.InvariantCultureIgnoreCase) == -1)
                return content;
    
            var html = new HtmlDocument();
            html.LoadHtml(content);
    
            var macroNodes = html.DocumentNode.SelectNodes("//comment()[contains(., '<?UMBRACO_MACRO')]");
            if (macroNodes == null || !macroNodes.Any())
                return content;
    
            foreach (var c in macroNodes)
            {
                var macroMatch = marcoFormat.Match(c.InnerHtml);
    
                if(macroMatch.Value.IndexOf("macroalias", StringComparison.InvariantCultureIgnoreCase) == -1)
                    continue;
    
                var attributes = helper.ReturnAttributes(macroMatch.Value.ToString()).Cast<DictionaryEntry>().ToDictionary(x => x.Key.ToString(), y => (object)y.Value);
    
                content = content.Replace(c.ParentNode.OuterHtml, UmbracoHelper.RenderMacro(attributes["macroalias"].ToString(), attributes).ToString());
            }
    
            return content;
    
        }
    
    }
    
  • Matt Cheale 8 posts 33 karma points
    Jul 27, 2016 @ 16:04
    Matt Cheale
    2

    I had a few issues with the class above, mainly that:

    • The content markup wasn't autoclosed where the parent node outer html was, so the replacement didn't work.
    • That the helper.ReturnAttributes was deprecated.

    I tweaked things this:

    public static class MacroUtilities
    {
        private static readonly Regex macroFormat = new Regex(@"(<\?UMBRACO_MACRO (?:.+?)?macroAlias=[""']([^""\'\n\r]+?)[""'].+?)(?:/>|>.*?</\?UMBRACO_MACRO>)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
    
        public static string RenderContentMacro(string content)
        {
            if (UmbracoContext.Current == null)
            {
                return content;
            }
    
            return RenderContentMacro(new UmbracoHelper(UmbracoContext.Current), content);
        }
    
    
        public static string RenderContentMacro(this UmbracoHelper UmbracoHelper, string content)
        {
            if (string.IsNullOrWhiteSpace(content))
            {
                return string.Empty;
            }
    
            if (content.IndexOf("UMBRACO_MACRO", StringComparison.InvariantCultureIgnoreCase) == -1)
            {
                return content;
            }
    
            var html = new HtmlDocument();
            html.LoadHtml(content);
            content = html.DocumentNode.InnerHtml;
    
            var macroNodes = html.DocumentNode.SelectNodes("//comment()[contains(., '<?UMBRACO_MACRO')]");
            if (macroNodes == null || !macroNodes.Any())
            {
                return content;
            }
    
            foreach (var c in macroNodes)
            {
                var macroMatch = macroFormat.Match(c.InnerHtml);
    
                if (macroMatch.Value.IndexOf("macroalias", StringComparison.InvariantCultureIgnoreCase) == -1)
                {
                    continue;
                }
    
                var attributes = Umbraco.Core.XmlHelper.GetAttributesFromElement(macroMatch.Value.ToString()).ToDictionary(x => x.Key, y => (object)y.Value);
                content = content.Replace(c.ParentNode.OuterHtml, UmbracoHelper.RenderMacro(attributes["macroalias"].ToString(), attributes).ToString());
            }
    
            return content;
    
        }
    
    }
    

    Thanks, it was a big help.

  • admiss 20 posts 100 karma points
    Aug 03, 2016 @ 22:53
    admiss
    0

    Does anyone know, how to make the Macro content editable in TinyMice3 RTE? The NoneEditable Plugin - or the Grid - is passing automatically the "umb-macro-holder mceNonEditable" class to Macros, which is preventing users from being able to change (i.e. edit&save) content in RTE.

    Wondering where to find & change it to "mceEditable" - or trying to figure out why is TinyMice passing mceNonEditable to Macros??

    Thanks

  • mayuri 11 posts 81 karma points
    Feb 13, 2017 @ 09:27
    mayuri
    0

    Hi Matt,

    Thanks for your solution. Its working fine for me :)

    Actually, I'm using u7dtg plugin for editor into my custom property editor, not the rte. So, it was showing 'Macro alias: AliasName' at fronend. But, now its rendering a perfect Macro.

Please Sign in or register to post replies

Write your reply to:

Draft