Copied to clipboard

Flag this post as spam?

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


  • Anna 16 posts 110 karma points
    Oct 14, 2014 @ 16:11
    Anna
    0

    Editable macro in Rich text editor

    Hello!

    Does anybody know how to make a macro editable in the Rich text editor?

    I have a case where I want to make ready made "code snippets" that the user can insert into the rte and then edit a part of them.

    For example, I have a Partial View Macro that can be added to a rte:

    ------------------------------------------------------------------------------------------

    @inherits Umbraco.Web.Macros.PartialViewMacroPage

    <div id="editable_macro">
        <p>Insert some content here</p>
    </div>

    ------------------------------------------------------------------------------------------

    When the macro is inserted into the rte, it is inserted ok there is that dotted line around it. But it is not possible to e.g. edit the text "Insert some content here" unless you switch to HTML mode, which the user will not be able to do.

    It had thought about adding a macro paramter of type Rich Text Editor, but unfortunately that type is not available for a parameter type.

    Thanks for any help!

    Anna

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 14, 2014 @ 16:22
    Dennis Aaen
    0

    Hi Anna and welcome to our.

    In order to do this, you will have to allow macros to be inserted into the Rich Text Editor. This is enabled on the macro itself.

    Go to your Back Office into the Developer section.
    Expand the Macros folder and select a macro. You will see that, besides the name and alias, the type of macro. You also have a setting to use the macro in the RTE. Make sure this is checked.



    Save your macro and go to the Content section. Select a content document that has a RTE and insert it where you want.

    Hope this helps,

    /Dennis

  • Anna 16 posts 110 karma points
    Oct 14, 2014 @ 16:40
    Anna
    0

    Hello Dennis,

    thank you for your quick answer. I have those two checked:

    and the macro renders like this in the rte:

    And when I select the text and try to write over it nothing happens.

    I'm using Umbraco version 7.1.8.

    Anna

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 14, 2014 @ 18:03
    Dennis Aaen
    0

    Hi Anna,

    Yep, my experience with edit the content from a macro that are showing in the Rich text editor it can be very difficult to do this.

    I have tried setting up an fresh Umbraco 7.1.8 installation and tried the same as you.

    And I have not been able to edited content in the macro, only if I took the HTML view.

    I can see it´s something with Read more from your previous post. Maybe you could try describe what content the macro should present, and what the user should be able to edit. Maybe it perhaps can be made in a more user-friendly way.

    I would try to give my best recommendations on how to do it, if you can tell a bit more on what type of content that you have in your macro.

    Looking forward to hear from you.

    /Dennis

  • Anna 16 posts 110 karma points
    Oct 15, 2014 @ 08:48
    Anna
    0

    Hi Dennis,

    the idea with this thing is to make a "read more" functionality that somebody could use  in the rte without having to know html.

    So I would have two macros: ReadMoreLink and ReadMoreContents.

    When clicking the link in ReadMoreLink, the contents of ReadMoreContents would be shown. I'm using bootstraps toggle, and the result would be like this:

    <a class="read_more_link" data-toggle="collapse" data-target="#read_more_about_something">Read more ...</a>

    <div id="read_more_about_something" class="collapse">
    <p>Here is some more information about something.</p>
    </div>

    So the <a> is what's in the ReadMoreLink Macro:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    <a class="read_more_link" data-toggle="collapse" data-target="#@Model.MacroParameters["toggleElementId"]">Read more ...</a>

    and the <div> is what's in the ReadMoreContents macro:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage  
    <div id="@Model.MacroParameters["id"]" class="collapse">
        <p>Insert some text here.</p>
    </div>

    The ReadMoreContents would have a parameter, id, to which you give the value read_more_about_something.

    The ReadMoreLink macro would have a parameter, toggleElementId, which would get the value read_more_about_something.

    So basically the idea was that the user could then type in any type of html in the place of "<p>Insert some text here.</p>" after adding the macro to the rte. As I said, it would be great if you could have added a parameter of type rte to the ReadMoreContents macro, but maybe it isn't possible.

    Anna

Please Sign in or register to post replies

Write your reply to:

Draft