Last week, I asked Lewis Goulden — a friend and former colleague — to name one thing in Sitecore he would like to learn or know more about. His answer was knowing how to add menu options to the Item context menu — particularly the ‘Publish Now’ and ‘Publish Item’ menu options found in the Publish ribbon.
I remembered reading a few blog articles in the past articulating how one would accomplish this. I needed to dig to find any of these articles.
After googling — yes googling is a verb in the English language — a few times, I found an article by John West discussing how to do this and another by Aboo Bolaky. I had also discovered this on pages 259-260 in John West’s book Professional Sitecore Development.
Instead of passing these on to Lewis and wishing him the best of luck in his endeavours augmenting his context menu — definitely not a cool thing to do to a friend — I decided to capture how this is done in this post, and share this with you as well.
Plus, this article sets the cornerstone for part two: augmenting the item context menu using a custom command and pipeline.
Here’s what the context menu looks like unadulterated:
My basic goal is to add a new ‘Publishing’ fly-out menu item containing ‘Publish Now’ and ‘Publish Item’ submenu options betwixt the ‘Insert’ and ‘Cut’ menu options.
In other words, I need to go find the ‘Publish Now’ and ‘Publish Item’ menu items in the core database and add these to the Item context menu.
So, I had to switch over to the core database and fish around to find out the command names of the ‘Publish Now’ and ‘Publish Item’ menu items.
First, I looked at the Publish ribbon (/sitecore/content/Applications/Content Editor/Ribbons/Ribbons/Default/Publish):
The Publish ribbon helped me hone in closer to where I should continue to look to find the publishing menu items.
Next, I went to the Publish strip:
The Publish strip pretty much tells me I have to keep on digging. Now, I have to go take a look at the Publish chunk.
In the Publish chunk, I finally found the ‘Publish Now’ menu button:
I made sure I copied its click field value — we’ll be needing it when we create our own ‘Publish Now’ menu item.
I then navigated to /sitecore/content/Applications/Content Editor/Menues/Publish to snag the command name of the ‘Publish Item’ menu option:
Now, I have all I need to create my own ‘Publishing’ fly-out menu item and its ‘Publish Now’ and ‘Publish Item’ submenu options.
I then went to /sitecore/content/Applications/Content Editor/Context Menues/Default and added a new Item named ‘Divider’ — using the /sitecore/templates/System/Menus/Menu divider template — after the Insert menu option, and created my ‘Publishing’ fly-out menu item using the /sitecore/templates/System/Menus/Menu item template.
Thereafter, I created my ‘Publish Item’ menu item using the same template as its parent ‘Publishing’. I then put the command name for the ‘Publish Item’ menu option found previously into my item’s Message field:
Next, I created my ‘Publish Now’ menu item using the same template as its parent and sibling. I put in the ‘Publish Now’ menu item’s Message field the command name for the ‘Publish Now’ menu option found during my expedition above:
Now, let’s take this for a test drive. I switched back to the master database and navigated to my Home node. I then right-clicked:
As you can see, the ‘Publishing’ fly-out menu appears with its publishing submenu options. Trust me, both menu items do work. 🙂
All of this without any code whatsoever!
In part 2 of this article, I will step through building a custom command coupled with a custom pipeline that compose the logic for a custom menu item for the Item context menu that copies all subitems of an ancestor item to a selected destination.
Happy coding and have a Sitecorelicious day! 🙂