More in this section

Forums / Developing with Sitefinity / auto mailto in content editor

auto mailto in content editor

5 posts, 1 answered
  1. Michael
    Michael avatar
    12 posts
    Registered:
    13 Oct 2008
    13 Apr 2009
    Link to this post
    Is there a way to have the RadEditor control for the generic content module to create auto mailto code for email addresses that are typed into the content area?
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    15 Apr 2009
    Link to this post
    Hi Michael,

    Yes, there is such a way. In order to do this, you should create a custom RadEditor ContentFilter. It should use a regular expression to match all e-mail address, and to add mailto: infront of them.
    Here are the steps:
    1. Map the needed template, in order to change the RadEditor's behavior. We are using embedded templates that could not be changed by default. Please take a look at How to map a view to an external template, in Sitefinity 3.6 if you are new to this.

    2. Add the ContentFilter. You might take a look at these articles:
    I hope this helps.
    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
    Answered
  3. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    17 Sep 2009
    Link to this post
    Hi I followed these steps and used the following code but for some reason nothing happens when I switch between Design and HTML view.  Can you please advise?

    <script type="text/javascript"
    <!-- 
        // custom filter for email addresses 
        function OnClientLoad(editor, args) { 
            editor.get_filtersManager().add(new EmailFilter()); 
            //alert('test'); 
        } 
        EmailFilter = function() { 
            EmailFilter.initializeBase(this); 
            this.set_isDom(false); 
            this.set_enabled(true); 
            this.set_name("RadEditor filter"); 
            this.set_description("RadEditor filter description"); 
        } 
        EmailFilter.prototype = 
                                { 
                                    getDesignContent: function(content) { 
                                        var newContent = content; 
                                        /*var regExpEmail = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
                                        newContent = newContent.replace(regExpEmail, "<a href='mailto:$1'>$1</a>");
                                        alert(newContent);*/ 
                                        newContent = newContent.toUpperCase(); 
                                        alert('here'); 
                                        return newContent; 
                                    }, 
                                    getHtmlContent: function(content) { 
                                        var newContent = content; 
                                        //Make changes to the content and return it 
                                        newContent = newContent.toUpperCase(); 
                                        alert('test'); 
                                        return newContent; 
                                    } 
                                } 
        EmailFilter.registerClass('EmailFilter', Telerik.Web.UI.Editor.Filter); 
    --> 
    </script> 
     

  4. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    17 Sep 2009
    Link to this post
    Hey Devin,

    Just a few random thoughts:

    1.  Ensure that the <telerik:RadEditor> tag has the OnClientLoad property:

    <telerik:radeditor runat="server" ID="RadEditor1" SkinID="DefaultSetOfTools" OnClientLoad="OnClientLoad">  
        <Content> 
            <strong><br />&nbsp;Switch to Html mode to run the content filter.<br />&nbsp;You will see that the casing is changed to upper case.</strong> 
        </Content> 
    </telerik:radeditor> 

    2.  Make sure the External Template is mapped and in place.  Georgi linked the instructions above.

    3.  Make sure the web application gets restarted after the Telerik.Sitefinity.Configuration.ControlsConfig.xml file is put into place or changed.  This file is only processed during Application_Start.  Changes won't be seen until the web application is restarted.

    I'm not sure if any of this helps, but those are my stabs in the dark.   ;)    Best of luck.
  5. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    17 Sep 2009
    Link to this post
    Hi Gabe,
    Thanks for the reply, I forgot to set the OnClientLoad property.
Register for webinar
5 posts, 1 answered