Best Practices Development

Sitecore Tip #8: How to Properly Use Sitecore Edit Frames

One of the most impressive features of Sitecore is its Page Editor, therefore, developing for it is one of the Sitecore best practices. However, just like with anything in Sitecore, you have to know how to properly develop for it, and using Edit Frames is a must in any Sitecore solution. This article focuses on highlighting the importance of using Edit Frames and attempts to promote creative thinking when developing for Page Editor by uncovering the true Edit Frame potential.

What is a Sitecore Edit Frame?

Sitecore provides a long list of field types that can be used for storing data. These fields are generally separated into two major categories: simple and complex fields. I will not go in depth about their definitions, these types of Sitecore fields have already been described extensively. In order to make simple fields editable in Page Editor, we use a special control type called FieldRenderer, which is very straight-forward.

Although, the simple fields are in fact the most used fields in Sitecore, the complex ones also have a pretty fair share of the “field market” in the CMS. Unfortunately, many Sitecore developers solely focus on making the simple fields editable in Sitecore (if any at all, and yes, I have seen that done), but why? Would you, as a developer or product manager, force your editors to switch to the Content Editor, or the awkward page-split in Page Editor to edit complex-type fields?

This is where Edit Frames come very handy – it allows developers to expose all types of fields in Page Editor, making the content editing experience much more streamlined.

How do Sitecore Edit Frames work?

The name Edit Frame is somewhat self-explanatory. Not much of a rocket science here – it is simply a control that provides editing capabilities in Page Editor Editing mode, commonly used for editing related item’s fields that cannot be exposed via the FieldRenderer controls (usually, but not always, read on…).

The Edit Frame control wraps any element or text in markup and when in Page Editor – and when in the Editing mode – displays a frame around the wrapped elements with a button panel. The default Web Edit buttons include: Edit related item, Insert, and Edit.

The default configurations for these buttons are located in the Core database under /sitecore/content/Applications/WebEdit/Edit Frame Buttons; by the way this is something I am an opponent of as it violate the Separation of Concerns principle in many ways (the location along with the lack of documentation may be part of the reason for the EditFrame’s low popularity). While the Edit related item and Insert are self-explanatory, the Edit button requires a bit of attention to get it to work properly:

  • First, please be nice and update the Header and ToolTip fields of the Edit button. Remember, that people from Mars, aka Content Editors, love help messages.
  • Second, place the field names to be made editable into the Fields field separated by a “pipe” character – |

The following two articles should cover the majority of basic EditFrame implementation scenarios:

Why is using Sitecore Edit Frames a best practice?

Well, by this point you might be thinking, “ok, I get it, Edit Frames make complex fields editable”, but don’t click away from the page just yet. Making Sitecore complex fields available is only one of many reasons for using Edit frames.

Sitecore poorly implemented slideshow in Page Editor.

Sitecore poorly implemented slideshow in Page Editor.

Properly implemented slideshow in Sitecore Page Editor.

Properly implemented slideshow in Sitecore Page Editor.

Remember, that the goal of developing for Page Editor is making the editing experience user-friendly and streamlined, thus, as Sitecore developers, we should not only focus of presenting data on a web page to regular user, but also providing a great editing experience.

Are your image carousels editable in Page Editor? Are you able to edit the text shown over the images on each slide, choose the order of slides, add new, and delete? Although, we can manage to satisfy ordering, inserting, and deleting via the rendering Page Editor Buttons, whenever developers try to use FieldRenderers on components like slideshows that are animated or modified in any way by client-side JavaScript libraries like jQuery, they end up with a mess for the editing frames, fighting for the z-index, and laying one over the other. This results in a very messy and confusing experience, and if that wasn’t enough – the animation of the slideshow continues rotating slides. As a result this implementation is not user-friendly by any means, and no wonder some Sitecore users look for other CMS alternative – experience is one of the key elements that is unfortunately often sacrificed for the sake of time and budget.

Consider, instead, in the rendering or sublayout markup to check for the Page Editor, and when in the Editing mode, modify the entire slideshow to appear as a list of slide thumbnails (created by re-sizing the slide images using the Sitecore image parameters) wrapped in an Edit Frame. To edit each thumbnail, including the image, text, and any other fields located on the slide-item, Content Editors can simply click the Edit button on the Edit Frame panel. To preview changes, users can simply switch to the Preview mode of the Page Editor, and the slideshow will revert to the normal animated mode showing the effect of the performed changes.

As you can see, with this implementation, the editing experience is much more streamlined and less confusing. Content Editors can clearly see all slides that are in the slideshow at a high level and easily edit any information on any slide.

Wait there is more!

Not to sound like a ShamWow guy, but there is indeed more. After looking at the types of buttons that can be created under Web Edit in the Core database, it is easy to see that these buttons use Sitecore commands to execute their actions. Knowing this, we can now add more power to our Edit Frames beyond simply editing the item. We could add some processing buttons that provide additional functionality, or perform certain tasks.

Now that’s where the flexibility of the Sitecore Edit Frame truly shines. Can you think about any use cases where this would came in handy? How about adding a button for making list item featured, so it always appears first? or exposing certain actions to editors depending on their role?

As you can see, Sitecore Edit Frames are a must-have in any Sitecore developer’s arsenal. Content Editors appreciate an intuitive and streamlined editing experience, and we, as developers should always strive to think outside of the box, and come up with creative solutions to these problems.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.