Today I want to share an idea of a lightweight customization for Sitecore CMS

The basic problem reported by one of the editors who uses on the daily basis, is that when a content item is approved in workflow there is no way to see what’s inside of a rich text field easily. All field buttons are grayed out thus disabled:

…so the only way is to click “Lock and Edit” which creates a new version: lock-and-edit

As you can imagine, this is not generally acceptable. If your non-admin editor user simply wants to see what’s in there, you don’t want a new version to be created.

Now it is worth mentioning that the item which is approved, unlocked is disabled for editing only if “RequireLockBeforeEditing” setting is set to true which is often the case, since you would want to have “Lock and Edit” in place so new version of the approved content is created.

Same goes along with the items that are locked. If there is a locked item, I would still want to see the content of the rich text field in read-only mode.

So one of the easiest ways I could think of to address this was enable “preview” of the rich text field in a modal dialog on double click.

Tech support provided the following solution which enabled the double click on disabled rich text field and showed the “preview” version of the field in a modal dialog:image

To make it work, follow these steps:
1. Open Preview.aspx under /sitecore/shell/Controls/Rich Text Editor.
2. Locate the scEdit() function and comment out the first IF statement:

function scEdit() {

//if (scDisabled == "1") {

// return;

// }

var form = scGetForm();  
...
  1. Compile the following code:
namespace Company.Web.Fields  
{

using Sitecore.Diagnostics;

using Sitecore.Shell.Applications.ContentEditor.RichTextEditor;

using Sitecore.Web.UI.Sheer;

public class RichText : Sitecore.Shell.Applications.ContentEditor.RichText

{

protected new void EditText(ClientPipelineArgs args)

{

Assert.ArgumentNotNull(args, "args");

if (Disabled && !args.IsPostBack)

{

var url = new RichTextEditorUrl

{

Conversion = RichTextEditorUrl.HtmlConversion.Runtime,

Disabled = Disabled,

FieldID = FieldID,

ID = ID,

ItemID = ItemID,

Language = ItemLanguage,

Mode = string.Empty,

Source = Source,

Url = "/sitecore/shell/Controls/Rich Text Editor/Preview.aspx",

Value = Value,

Version = ItemVersion

};

var str = url.GetUrl();

SheerResponse.ShowModalDialog(str.ToString(), "800px", "500px", string.Empty, true);

args.WaitForPostBack();

}

base.EditText(args);

}

}
}
  1. In web.config, add your own controlSource reference to the namespace above:
<controlSources>

<source mode="on" namespace="Sitecore.Web.UI.XmlControls" folder="/sitecore/shell/override" deep="true" />
...

<source mode="on" namespace="Company.Web.Fields" assembly=" Company.Web" prefix="custom" />
</controlSources>
  1. In the core database, locate the Rich Text field item (/sitecore/system/Field types/Simple Types/Rich Text) and adjust the value of the “control” field:

_custom:RichText

_Note that the prefix is used from the controlSource reference above.

Simple and lightweight customization that should bring some value. Sitecore rocks

Tested on 6.1, expected to work on 6.0.x and 6.2.

|