Copied to clipboard

Flag this post as spam?

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


  • Chris Seager 16 posts 107 karma points
    Jan 12, 2018 @ 11:40
    Chris Seager
    0

    Macro Rich Text Editor Not Parsing Local Links

    Morning

    I have created a rich text editor macro which only allows centering text and adding a link.

    Currently everything is working as intended except for adding a link to the text.

    If you manually type the in the url box the link works correctly.

    if you decide to pick from the list of a location on the site the href of the link is set too "%7BlocalLink:1055%7D" which causes to display an error.

    Controller:

    angular.module("umbraco")
        .controller("widetexteditor.controller", function ($scope) {
    
            $scope.textInput = {
                label: 'Body Text',
                description: 'Rich text editor',
                view: 'rte',
                value: $scope.model.value,
                config: {
                    editor: {
                        toolbar: ["alignleft", "aligncenter", "link"],
                        dimensions: { height: 400}
                    }
                }
            };
            $scope.$watch('textInput.value', function (newValue, oldValue) {
                $scope.model.value = newValue;
            });
        });
    

    View:

    <div ng-controller="widetexteditor.controller">
        <ng-form>
            <umb-editor model="textInput"></umb-editor>
        </ng-form>
    </div>
    

    Manifest:

    {
                alias: "PageWideTextAreaDataType",
                name: "Page Wide Text Box",
                isParameterEditor: true,
                editor: {
                    view: "~/App_Plugins/widetexteditor.html",
                    valueType: "text"
                }
    
  • Chris Seager 16 posts 107 karma points
    Jan 12, 2018 @ 12:10
    Chris Seager
    0

    I have found some old information on bugs that should be fixed about local links not being parsed. This kind of feels similar hopefully someone will be able too help.

  • Daniel Chenery 119 posts 465 karma points
    Jan 15, 2018 @ 09:20
    Daniel Chenery
    101

    Hi Chris,

    I've stumbled across this many times. Along with other things not rendering properly in Macro RTE's

    You can use the following code to fix your local links URL (note, I've made a function to save repeating the if statement)

    public string RenderRTEContent(string content) {
        if (UmbracoContext.Current != null)
        {
            content = TemplateUtilities.ParseInternalLinks(content, UmbracoContext.Current.UrlProvider);
        }
    
        return content
    }
    

    Then in your view, call it like so

    @Html.Raw(RenderRTEContent(rteContent))

  • Chris Seager 16 posts 107 karma points
    Jan 15, 2018 @ 17:56
    Chris Seager
    1

    Thank you Daniel using Parse Internal Links something i was not aware of has fixed my issue.

Please Sign in or register to post replies

Write your reply to:

Draft