Copied to clipboard

Flag this post as spam?

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


  • Elliott Brown 41 posts 211 karma points
    Mar 21, 2017 @ 09:32
    Elliott Brown
    0

    Custom Macro Parameter Editor - RTE

    The code below now works.

    I hope this will help others too as there isn't a lot of documentation about this exactly. I want to use a RTE (rich text editor) within a macro I've created to handle page sections. I have successfully rendered the RTE within the macro. I can select my macroRte from the macro parameters panel. It even renders where I edit the values of my page section. I have attributed the alias of "macroRte" to the parameter. However, it is not storing the values. Each time I press submit it is wiping the content. I'm no Angular expert but i think that's the problem. Code below. Thank you.

    View

    <div ng-controller="CustomSectionEditController">
    <ng-form>
        <umb-editor model="macroRte"></umb-editor>
    </ng-form>
    </div>
    

    Controller

    angular.module("umbraco").controller("CustomSectionEditController", function ($scope) {
    $scope.macroRte = {
        label: 'bodyText',
        description: 'Load some stuff here',
        view: 'rte',
        value: $scope.model.value,
        config: {
            editor: {
                toolbar: ["code", "undo", "redo", "cut", "styleselect", "bold", "italic", "alignleft", "aligncenter", "alignright", "bullist", "numlist", "link", "umbmediapicker", "table", "umbembeddialog"],
                stylesheets: ["rte"],
                dimensions: { height: 400 },
                valueType:"STRING"
            }
        }
    },
    $scope.$watch("macroRte.value", function (newValue, oldValue) {
        $scope.model.value = newValue;
    });
    });
    

    Render

    @inherits Umbraco.Web.Macros.PartialViewMacroPage  
    <div class="lh-text">
        @Model.MacroParameters["whateverYourParameterAliasIs"];
    </div>
    

    I hope this helps!

  • Elliott Brown 41 posts 211 karma points
    Mar 21, 2017 @ 10:18
    Elliott Brown
    100

    I've actually solved the problem using this github https://github.com/engern/Umbraco-custom-macro-parameters/tree/master/App_Plugins/MacroRichText

    I have made the changes to the code above, meaning that the code is now working.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies