Custom Command in 4 simple steps
- Create a class by inheriting (Sitecore.Shell.Framework.Commands.Command)
- Implement Execute method --> Public override void Execute(CommandContext context) { SheerResponse.Alert("Hello from Custom Command"); }
- Implement QueryState method (this method is optional based on the need) -->Public override CommandState QueryState(CommandContext context) { return context.Items[0].Children.Count == 0 ? CommandState.Hidden : base.QueryState(context); }
- Adding Following config tag in Commands.config located under (Sitecore/website/App_Config)
- <command name=”item:[class name in all lower case letters]” type=”[fully qualified namesspace.classname, namespace]”/>
- Go to Sitecore Desktop and switch to “CORE” database
- Select “Sitecore/Content/Applications/Content Editor/Context Menus/Default”
- Create a new menu item
- fill in the item fields --> Display name, Icon, Message = item:classname(id=$Target)
- Save the changes and switch to “MASTER” database
- Right Click on any Sitecore item to notice newly added menu item
No comments:
Post a Comment