Adding a custom command to item context menu

The context menu is designed to increase the efficiency of content authors. The requirements may vary for content authors across different organizations.

In this recipe, we will create a menu item in the context menu of a Sitecore item that will display the number of children that the selected item contains. In the same way, you will be able to create a command button for the Content Editor and Experience Editor ribbons as well.

How to do it…

We will first create a Command class:

  1. In the SitecoreCookbook project, create a GetChildCount class in the Commands folder. Inherit the class from Sitecore.Shell.Framework.Commands.Command.
  2. Override the Execute() method of the Command class to apply a command action ...

Get Sitecore Cookbook for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.