Customize an XML Control

Author: Alexey Romaniuha
Posted: 1/24/2008 12:00:00 PM

Question: How to customize an XML control used inside the Sitecore client?

Recommended preliminary reading:

Most XML controls used within the Sitecore client are commonly placed below the /sitecore/shell/controls and /sitecore/shell/applications folders (refer to the <controlSources> section of your web.config).
And almost each of them can be customized which makes it possible to implement custom behavior within the Sitecore client.
The following are the steps required to override the standard control’s behavior. As an example we’ll use an Insert Link dialog used in the Rich Text Editor.

  1. The XML control responsible for populating the Insert Link dialog is located in the following file:
    /sitecore/shell/Controls/Rich Text Editor/Insert link/Insert link.xml
    . Copy this file to /sitecore/shell/override folder. This will ensure that new control will be used instead of the standard one.
  2. This dialog uses the Sitecore.Shell.Controls.RichTextEditor.InsertLink.InsertLinkForm class as a code beside. Inherit this class and implement some custom logic.
    A simple example is:

    public class CustomInsertLinkForm : Shell.Controls.RichTextEditor.InsertLink.InsertLinkForm
           protected override void OnLoad(EventArgs e)
                Sitecore.Diagnostics.Log.Info("Insert Link dialog custom behavior.", this);

  3. Compile the assembly and place it in the \bin folder of your solution.
  4. Set the codebeside of the control placed in the override folder to point to the new class, e.g.:

    <CodeBeside Type="Sitecore.CustomInsertLinkForm,Sitecore.Custom"/>

Now each time the Insert Dialog dialog is accessed a custom message will be logged.
You can implement any custom logic using this approach, such as change contol's appearance and behavior.