Create a Custom Item Editor in Sitecore

Custom Item Editors are awesome! In the right circumstances they really add a ton of value for the content author and give you the developer a ton of control. This will be the first in a series of posts in how to make and use Sitecore custom item editors.

What is a custom item editor?

Item editors are tabs that you can add to any item. The tab contents are custom endpoints that get iframed into Sitecore. This will become clearer as we see some examples.

When you click the root Sitecore item, you will see a “Folder” tab appear. If you inspect the html that loads when you click the tab, you’ll see that the content is iframed into the content editor inside the “EditorFrames” div. Here is an example of the url.

[protocol]://[host]/sitecore/shell/-/xaml/Sitecore.Shell.Applications.ContentEditor.Editors.Folder.aspx?id=%7B11111111-1111-1111-1111-111111111111%7D&la=en&language=en&vs=1&version=1&database=master&readonly=0&db=master

There is some important data being passed via query string to the page that will be iframed. These values include item ID, language, version, and database.

If you browse to that url, you’ll see this:

In Sitecore, it looks like this.

Pretty cool. Let’s make one.

Making a custom item editor in Sitecore

Log into Sitecore, and go to the Desktop.

Then switch to the “Core” database.

Open the “Content Editor” for the “Core” database and navigate here: /sitecore/content/Applications/Content Editor/Editors/Items

Click on the “Folder” item and review the settings. The “Items” folder doesn’t have insert options so “Duplicate” the “Folder” item and give it a good name. I’ll call mine “Sample” for now. Note the Url field.

Here is the code I added to the sample.aspx page.

<%@ Page language="c#" %>
<html>
<body>
<h1>Hello World!</h1>
</body>
</html>

Let’s wire this up to an item now. Switch back to the master database and open the “Content Editor”.

I’m going to add my new editor to the “Sample Item” template.

Locate the standard values for the Sample Item and find the “Editors” field. Click “Edit” and expand the items folder, then choose the “Sample” item. Click “Ok”

Make a new “Sample Item”. When that item is selected, you’ll see a “Sample” tab and our custom aspx page displayed. Here is the iframe url: /sitecore/shell/customEditors/sample.aspx?id=%7B1C85FA12-2DC2-492F-89E8-1964697C943C%7D&la=en&language=en&vs=1&version=1&database=master&readonly=0&db=master

Pretty easy to make and very powerful once we dig into some use cases. In the next series of posts, we’ll explore some of these use cases.

About Phil Paris

Hi, my name is Phil Paris and I’m a Sitecore Architect and general Sitecore enthusiast. I’ve been working with Sitecore since 2013. Through this blog I will be sharing Sitecore insights, tips and tricks, best practices and general knowledge with the hopes to further the community at large. Please feel free to reach out to me at any time!

View all posts by Phil Paris →