Page editor and structuring related items

Since Sitecore 6.4.1 I’ve been working alot with the Page Editor in Sitecore and how to make the editor experience as good as possible. I’ve found that it’s hard to keep the editor mainly editing in the Page Editor due to various limitations. One of those are structure.

My latest Sitecore solution, using Sitecore 7.1, utilizes the designer in the Page Editor to it’s full potential where I allow the editor to completely reorganize the content the way they see fit using rows, columns and blocks. As you can imagine this puts a higher demand on structure as one page can consist of several sub layouts which each have it’s own item and then add up that you have loads of pages constructed this way.

Idealy the editor could manage the structure at the same time as he/she is adding the content to the page in the page editor. However this is not possible out of the box in Sitecore.

Many of you might at this time say Item Buckets. However this requires the editor to search for the content and my experience with our customers is that many of them aren’t ready for this because they like to manage their own structure.

Well the solution to my problem ended up being quit simple. All I wanted was to have the context menu you have in the content editor. I also remebered that this context menu was available in the media browser when selecting media, so I started out looking there.

I found this attribute on the TreeviewEx in the media browser xml file (\sitecore\shell\Applications\Media\MediaBrowser\MediaBrowser.xml):

ContextMenu='Treeview.GetContextMenu("contextmenu")'

I made a copy of the SelectRenderingDatasource.xml (\sitecore\shell\Applications\Dialogs\SelectRenderingDatasource\SelectRenderingDatasource.xml) file to put in the override folder and added that attribute to the TreeviewEx in that file and the Context Menu was there. However it ended up opening a little off as you can see in this video http://screencast.com/t/FkwhxHcM. So I had to make some adjustments to the code opening the context menu.

I ended up altering the attribute to this:

ContextMenu='Treeview.GetContextMenu("dialoguemenu")'

And make the following changes to the \sitecore\shell\Controls\Browser.js, I replaced this part:

if (dimensions.width > 0) {
  switch (data.where) {
    case "contextmenu":
      x = evt.pageX || evt.x;
      y = evt.pageY || evt.y;
    break;

With this:

if (dimensions.width > 0) {
  switch (data.where) {
    case "contextmenu":
    case "dialoguemenu":
      x = evt.pageX || evt.x;
      y = evt.pageY || evt.y;
    break;

And wrapped this part:

var vp = ctl.viewportOffset();
x += vp.left;
y += vp.top;

With this if case:

if (data.where != "dialoguemenu") {
  var vp = ctl.viewportOffset();
  x += vp.left;
  y += vp.top;
}

This made the context menu pop up where the mouse was when right clicking.

I know this might not be the optimal solution. I would prefer that you could configure the rendering with a folder template like you do with a datasource template which you could have a dedicated button for like the “Create new content” button and not relying on a context menu. This would increase the experience with the Page Editor it think. Unfortunatly I didn’t have more time to look into this, maybe next time 🙂

Leave a Reply

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