Super Field Editor

Anyone who has used the Experience Editor much knows that when you need to edit a field on an item, that’s not exposed by a Field Renderer or Field Edit button, your only option is to click the edit related item button. This will submit a postback and open a strange split screen view of the Content Editor and Experience Editor which most people find off putting.

My solution is to dynamically add a Field Editor button that exposes all custom fields of the datasource item.

chrome

From here all fields (except standard values fields) are exposed.

fields.png

	///
<summary>
	/// Injects a field editor button into the xEditor rendering chrome, exposing all fields in a field editor.
	/// </summary>

	public class SuperFieldEditor : GetChromeDataProcessor
	{
		public override void Process(GetChromeDataArgs args)
		{
			Assert.ArgumentNotNull(args, "args");
			Assert.IsNotNull(args.ChromeData, "Chrome Data");
			if (!"rendering".Equals(args.ChromeType, StringComparison.OrdinalIgnoreCase))
			{
				return;
			}
			//We need to ensure that the cache is fully populated
			args.Item.Fields.ReadAll();
			var fields = string.Join("|", args.Item.Fields.Where(f => !f.Name.StartsWith("__")).Select(f => f.Name));
			AddButtonsToChromeData(new[] {
				new WebEditButton
				{
					Click = string.Format("webedit:fieldeditor(fields={0}, command={{007A0E9E-59AA-48BB-84F2-6D25A8D2EF80}})", fields),
					Icon = args.Item.Appearance.Icon,
					Tooltip = "Edit the fields for "+args.Item.Name,
					Header = "Edit fields",
					Type = "sticky" // sticky keeps it from being hidden in the 'more' dropdown
				}
			}
			, args);
		}
	}

Finally this code is wired up through a simple sitecore config file.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
	<sitecore>
		<pipelines>
			<getChromeData>
				<processor type="[NAMESPACE].SuperFieldEditor, [ASSEMBLY NAME]" />
			</getChromeData>
		</pipelines>
	</sitecore>
</configuration>

This will basically have your bases covered. Whenever there’s a hidden value that you would like to have users edit, such as an input placeholder, it will already exist.