How do Sitecore commands work in the cms?

Under the hood the Sitecore api offers huge amounts of functionality. When you are using the cms environment, chances are you are triggering this functionality via sitecore commands.

Most buttons in the cms are tied into these commands so how do you pair up specific buttons to specific code?

There is an excellent Firefox plugin – Firebug, which is essential if you do a lot of web development. If you haven’t ever used this, download it now!

Once installed, run through the following steps:

  1. Fire-up your cms environment inFirefox (once firebug is installed)
  2. Activate firebug and select ‘inspect element’ – then click the button you are interested in
  3. Check the firebug window for the JavaScript attached to the button click – this should be wrapped in a sitecore form post JavaScript method eg javascript:return scForm.postEvent(this,event,’item:setdisplayname’)
  4. Open /app_config/commands.config and search for the command name. Examples of this are: item:setdisplayname, item:publish
  5. Find the assembly referenced in the commands file and fire up your favourite decompiler eg reflector or ilspy and search for eg <command name=”item:setdisplayname” type=”Sitecore.Shell.Framework.Commands.SetDisplayName,Sitecore.Kernel” />

You should now have a route into the source code for each button in the cms!

Leave a Reply

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