Sitecore Commands

Sitecore Commands

Sitecore Commands

  • Strings that are defined in App_Config/Commands.config file
  • Specified in the Click field of most buttons in the Sitecore user interface
  • Provide a mapping for ribbon items and menus to the Sitecore classes 

Nested Sitecore Commands

  • Used when a Sitecore command should be called by another Sitecore command
  • Example: chrome:common:edititem({command:"webedit:open"})
  • The chrome:common:edititem command calls the webedit:open command

Commands.config

  • Contains the command name and type string
  • The name must be specified in lower case
  • The type string is in the format <namespace>.<class name>, <assembly name>
  • The type is the class that inherits from Sitecore.Shell.Framework.Commands.Command

Command Class

  • Implement an abstract method
  • Public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context)
  • The context parameter passes the current item in context.Items[0]

Sources