+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Rich Text Summary Field

Rich Text Summary Field

3 posts, 0 answered
  1. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    15 Jul 2010
    Link to this post
    Hello I have a module that is based of the News Module. It has a bunch of custom meta fields but one of them needs rich text like the Description field. I thought I'd use the Summary field and just change it from a TextBox to a radEditor, but it doesn't seem to be working. Here's what I have:

    Metafield:
    <add key="Jobs.Summary" valueType="LongText" visible="True" searchable="True" sortable="True" defaultValue="Enter Contact Details"/>

    newsItemEdit.ascx
    <h3>
                <asp:Literal ID="Literal13" runat="server" Text="<%$Resources:Content %>"></asp:Literal>
                * <em id="contentEditorLabel" runat="server"></em>
            </h3>
            <fieldset class="set">
                <div class="setIn">
                      
    <telerik:RadEditor 
                        runat="server" 
                        ID="Editor" 
                        ContentAreaCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css"
                        ToolsFile="~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml" 
                        Skin="WebBlue"
                        NewLineBr="False" 
                        Width="95%"
                          
                        ContentFilters="EncodeScripts,FixUlBoldItalic,FixEnclosingP,IECleanAnchors,MozEmStrong,ConvertFontToSpan,ConvertToXhtml,IndentHTMLContent">
                        <ImageManager viewpaths="~/Images" uploadpaths="~/Images" deletepaths="~/Images" />
                        <MediaManager viewpaths="~/Files" uploadpaths="~/Files" deletepaths="~/Files" />
                        <FlashManager viewpaths="~/Files" uploadpaths="~/Files" deletepaths="~/Files" />
                        <DocumentManager viewpaths="~/Files" uploadpaths="~/Files" deletepaths="~/Files" />
                        <CssFiles>
                                    <telerik:EditorCssFile Value="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorCssFile.css" />
                                </CssFiles>
                    </telerik:RadEditor>
                    <script type="text/javascript">
      
                            Telerik.Web.UI.Editor.CommandList["LibraryImageManager"] = function(commandName, editor, args)
                            {
                               var editorArgs = editor.getSelectedElement();
                               if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                                    editorArgs = editor.getSelection();
                                 
                               var myCallbackFunction = function(sender, args)
                               {
                                    if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "IMG")
                                        args.parentNode.replaceChild(editorArgs, args);
                                    else
                                    {
                                        var cloned = args.cloneNode(true);
                                        var div = args.ownerDocument.createElement("DIV");
                                        div.appendChild(cloned);
                                        editorArgs.pasteHtml(div.innerHTML);
                                    }
                               }
                               editor.showExternalDialog(
                               '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx") %>',
                               editorArgs, 
                               750, 
                               600, 
                               myCallbackFunction, 
                               null, 
                               'ImageLibraryDialog', 
                               true, 
                               Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                               false, 
                               true)
                            };
      
                            Telerik.Web.UI.Editor.CommandList["LibraryDocumentManager"] = function(commandName, editor, args)
                            {
                               var editorArgs = editor.getSelectedElement();
                               if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                                    editorArgs = editor.getSelection();
                                 
                               var myCallbackFunction = function(sender, args)
                               {
                                    if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                        args.parentNode.replaceChild(editorArgs, args);
                                    else
                                    {
                                        var cloned = args.cloneNode(true);
                                        var div = args.ownerDocument.createElement("DIV");
                                        div.appendChild(cloned);
                                        editorArgs.pasteHtml(div.innerHTML);
                                    }
                               }
                               editor.showExternalDialog(
                               '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/DocumentEditorDialog.aspx") %>',
                               editorArgs, 
                               750, 
                               600, 
                               myCallbackFunction, 
                               null, 
                               'ImageLibraryDialog', 
                               false, 
                               Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                               false, 
                               true)
                            };
      
                            Telerik.Web.UI.Editor.CommandList["LinkManager"] = function(commandName, editor, args)
                            {
                               var editorArgs = editor.getSelectedElement();
                               if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                               {                                                                   
                                    var sel = editor.getSelection();  
                                    editorArgs = sel;
                                    editorArgs.Html = sel.getHtml();
                                    editorArgs.Text = sel.getText();                                    
                               }
                                 
                               var myCallbackFunction = function(sender, args)
                               {
                                    if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                        args.parentNode.replaceChild(editorArgs, args);
                                    else
                                    {
                                        var cloned = args.cloneNode(true);
                                        var div = args.ownerDocument.createElement("DIV");
                                        div.appendChild(cloned);
                                        editorArgs.pasteHtml(div.innerHTML);
                                    }
                               }
                               editor.showExternalDialog(
                               '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/LinksDialog.aspx") %>',
                               editorArgs, 
                               750, 
                               600, 
                               myCallbackFunction, 
                               null, 
                               'ImageLibraryDialog', 
                               false, 
                               Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                               false, 
                               true)
                            };
      
                            Telerik.Web.UI.Editor.CommandList["SetLinkProperties"] = function(commandName, editor, args)
                            {
                               var editorArgs = editor.getSelectedElement();
                               if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                                    editorArgs = editor.getSelection();
                                 
                               var myCallbackFunction = function(sender, args)
                               {
                                    if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                        args.parentNode.replaceChild(editorArgs, args);
                                    else
                                    {
                                        var cloned = args.cloneNode(true);
                                        var div = args.ownerDocument.createElement("DIV");
                                        div.appendChild(cloned);
                                        editorArgs.pasteHtml(div.innerHTML);
                                    }
                               }
                               editor.showExternalDialog(
                               '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/LinksDialog.aspx") %>',
                               editorArgs, 
                               750, 
                               600, 
                               myCallbackFunction, 
                               null, 
                               'ImageLibraryDialog', 
                               false, 
                               Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                               false, 
                               true)
                            };
                            var oldFunction = Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"]; //save the original Paste function
      
                                Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"] = function(commandName, editor, args)
                                {
                                    oldFunction(commandName, editor, args);
                                    var bd = document.getElementsByTagName("body")[0];
                                      
                                    if(/fullScreenMode/.test(bd.className)) {
                                        var rep = bd.className.match(' '+'fullScreenMode')?' '+'fullScreenMode':'fullScreenMode';
                                        bd.className=bd.className.replace(rep,'');
      
                                    } else {
                                        bd.className += bd.className?' '+'fullScreenMode':'fullScreenMode';
                                    }
                                };
                                  
                                // automated tests helper function
                                function InsertTextArea()
                                
                                    var editor = $find('<%=Editor.ClientID%>');
                                    editor.set_html('<textarea id="myTableToFind" style="overflow:hidden; height: 300px; width: 500px;" border="none"></textarea>'); 
                                }
                                  
                    </script>
                </div>
            </fieldset>
            <div class="bottom">
                <div>
                    <!-- -->
                </div>
            </div>
      
                    <h3>
                <asp:Literal ID="Literal3" runat="server" Text="Contact Information"></asp:Literal>
                * <em id="Em2" runat="server"></em>
            </h3>
            <fieldset class="set">
                <div class="setIn">
                    <telerik:RadEditor 
                        runat="server" 
                        ID="Summary" 
                        ContentAreaCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css"
                        ToolsFile="~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml" 
                        Skin="WebBlue"
                        NewLineBr="False" 
                        Width="95%"
                        ContentFilters="EncodeScripts,FixUlBoldItalic,FixEnclosingP,IECleanAnchors,MozEmStrong,ConvertFontToSpan,ConvertToXhtml,IndentHTMLContent">
                        <ImageManager viewpaths="~/Images" uploadpaths="~/Images" deletepaths="~/Images" />
                        <MediaManager viewpaths="~/Files" uploadpaths="~/Files" deletepaths="~/Files" />
                        <FlashManager viewpaths="~/Files" uploadpaths="~/Files" deletepaths="~/Files" />
                        <DocumentManager viewpaths="~/Files" uploadpaths="~/Files" deletepaths="~/Files" />
                        <CssFiles>
                                    <telerik:EditorCssFile Value="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorCssFile.css" />
                                </CssFiles>
                    </telerik:RadEditor>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Editor"
                        Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True"
                        ValidationGroup="EditNews">
                        <strong>
                            <asp:Literal ID="Literal4" runat="server" Text="<%$Resources:ContentEmpty %>"></asp:Literal></strong></asp:RequiredFieldValidator>
                </div>
            </fieldset>

    I'm pretty sure I've done this before and it worked. Am I missing something?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Jul 2010
    Link to this post
    Hi KMac,

    The control of type RadEditor with ID="Summary" should be added inside ContentMetaFields control otherwise the metakey should be persisted manually by using SetMetaData method of IContent object. To get the value of the metakey you should use GetMetaData method.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    15 Jul 2010
    Link to this post
    Of course. Thanks for quick response.
Register for webinar
3 posts, 0 answered