3

When accessing Hyperlink Manager from a Rich Text field, the default value of the "URL" field displayed on the modal is "http://". The code responsible for setting this value is hard-coded inside of "Telerik.Web.UI.dll" file. Would you know if it is possible to change that default value and how to achieve that?

Sitecore 9.0.2 (rev. 180604)

Telerik.Web.UI.dll line 428060

if(currentLink.name&&currentLink.name.trim()!="") // "anchor"
        {
            this._anchorName.value=currentLink.name;
            this._linkIdAnchor.value=currentId;
            this._tab.set_selectedIndex(1);
            return;
        }

        var href="http://"; //"link"

        if(currentLink.getAttribute("href")) {
            href=currentHref;
        }

        this._linkUrl.value=href;
        this._loadLinkTarget();
        this._linkTooltip.value=currentLink.title;
        this._linkIdLink.value=currentId;

        this._tab.set_selectedIndex(0);

Hyperlink Manager

Thanks

2
  • 1
    Can you add a screenshot and version details? Commented Jul 5, 2019 at 23:37
  • @MichaelWest thanks for asking that. Thoughts? Commented Jul 6, 2019 at 14:52

1 Answer 1

1

Assuming you want to ensure that all links inside rich text fields are https:// you could do the following:

public class EnsureHttpsInRichtextContent
{
    public void Process(SaveRichTextContentArgs args)
    {
        Regex regex = new Regex("http://", RegexOptions.IgnoreCase);
        args.Content = regex.Replace(args.Content, "https://");
    }
}

Add this to your configuration:

<sitecore>
 <pipelines>
  <saveRichTextContent>
    <processor type="MyAssembly.EnsureHttpsInRichtextContent, MyAssembly" />
  </saveRichTextContent>
 </pipelines>
</sitecore>

If you want to limit this to external links, have a look how to determine external links in this method:

 Sitecore.Shell.Controls.RichTextEditor.Pipelines.SaveRichTextContent.ProtectExternalLink, Sitecore.Client 
6
  • Thanks Mark. That worked. I know the next question does not belong to the original one, but when I add an External Link via Experience Editor ("Insert External Link" modal) the same pipeline is not called. I am trying to get the same behavior there. Any ideas? Commented Jul 8, 2019 at 13:43
  • @LeonardoFaggiani create a new post for that question.
    – Richard Seal
    Commented Jul 8, 2019 at 13:47
  • 1
    What if your content editor wanted to link to a site that doesn't have https tho?
    – Richard Seal
    Commented Jul 8, 2019 at 13:49
  • Richard, good question. Replacing with "//" instead of "https://" should work for both cases. Commented Jul 8, 2019 at 13:53
  • I have added a line of code in \sitecore\shell\Applications\Page Modes\ChromeTypes\FieldChromeType.js and got the same behavior on EE. externalLinkInserted: function(url) { url = url.replace("http:\/\/", "\/\/") if (this.isWatermark()) { this.chrome.element.update(""); } Commented Jul 8, 2019 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.