Sitefinity ASP.NET CMS - Content Management System

KB Article

Home >  Support >  Knowledge Base >  KB Article
How to extend the custom RadEditor dialogs - ID#961
Rating: Not rated
Last Modified: 4/7/2008
Related categories: Controls;

Article information

Article relates to

 Sitefinity 3.2 SP1

Created by

 Vassil Daskalov

Version 3.2 of Sitefinity comes with three custom dialogs for RadEditor which replace the built-in RadEditor tools for managing images, documents and links. Their purpose is to facilitate
placing images and documents from the Images and Documents module, as well as adding links to pages from the Sitefinity sitemap.
For the Link Manager dialog we decided to put only the basic options for managing links. These are the options for the URL address, the link text and the link tooltip. We removed the target=”_blank” option as this attribute is not XHTML compatible. However, we've had a couple of requests to put this option back. Below are the steps you need to follow to add it. Follow the same logic to insert other options such as the protocol to be used or a mailto link.

Here is what you need to do to set the target=”_blank” option.
Basically, you need to modify the ~/Sitefinity/Admin/ControlTemplates/Pages/Dialogs/LinkEditorDialog.ascx file. This file contains a few JavaScript functions but the ones you need to look at are the initDialog() and insertLink(). The first one is called once the Link Manager dialog is called from the RadEditor. It is used to initialize some parameters which are going to be used later. The second one is called once I’m Done is clicked, the dialog is closed and the link is inserted inside the RadEditor.

1. Add a control to maintain the option value.
In this case you need to add a checkbox control to allow a choice to open the link in a new browser window:

<li>  
    <asp:CheckBox runat="server" ID="openInNewWindow" Text="Open link in new window" />  
</li> 

TargetBlank

2. Populate the new control if needed.

You need to do this in the initDialog() function as you might select some link first and then click the Link Manager tool, expecting it to be populated with the information from the selection. In this case, the control should be found and filled with the selection information:

var selectionParameter = getRadWindow().ClientParameters; //return the arguments supplied from the parent page  
   if (selectionParameter.nodeName && typeof(selectionParameter.nodeName) != "undefined" && selectionParameter.nodeName == "A")  
   {  
        currentElement = clientParameters;  
     
        openInNewWindow = document.getElementById('<%= openInNewWindow.ClientID %>');  
        if (currentElement.target != "" && currentElement.target == "_blank")  
        {  
            openInNewWindow.checked = true;  
        }  
   }  
 

3. Get the information from the new control and supply it to the RadEditor.
You need to do this in the insertLink() function: get the needed control, take the necessary information from it and give it to the close argument like this:

function insertLink() //fires when the Insert Link button is clicked  
{  
   var closeArgument = currentElement;  
     
   openInNewWindow = document.getElementById('<%= openInNewWindow.ClientID %>');  
     
   if (openInNewWindow.checked)  
        closeArgument.target = "_blank";  
   else 
        closeArgument.target = "";  
     
   var radWindow = getRadWindow();  
   radWindow.argument = closeArgument;  
   radWindow.close(closeArgument); //use the close function of the getRadWindow to close the dialog and pass the arguments from the dialog to the callback function on the main page.  

This should do the job.
The whole code of the ~/Sitefinity/Admin/ControlTemplates/Pages/Dialogs/LinkEditorDialog.ascx file is provided in the attached .ZIP archive.


Article Files

  • LinkEditorDialog.zip



  • Article Comments

    There are no comments yet.
    Please Sign In to rate this article or to add it to your favorites.