LibrarySites.Banner

Repost: Add a Button to the Sitecore Content Editor Ribbon to Debug Any Item in Any Database

This blog post describes how you can add a button to the ribbon in the Content Editor application of the Sitecore ASP.NET CMS to debug the selected item in the current database.

This is a repost of http://sitecorejohn.spaces.live.com/blog/cns!960125F1D4A59952!189.entry.

Update 2.April.2013: See Add Debug Command to Content Editor in the Sitecore ASP.NET CMS.

The Sitecore browser-based debugger by default opens the home item of the managed Web site in the Web database. If you want to debug another item, you can navigate to that item, or enter its URL. If you want to debug in another database, you can add the sc_database query string parameter.

Or, to add a button to the Content Editor ribbon to debug the selected item in the selected database:

  1. Compile the required class into your project.
  2. Update the type attribute of the /configuration/command element named system:debug in the /App_Config/commands.config file to reference this class and the assembly that contains it.
  3. In the Sitecore browser-based desktop, use the database icon in the bottom right corner to select the Core database.
  4. In the Sitecore desktop, with the Core database selected, open the Content Editor and duplicate the /sitecore/content/Applications/Content Editor/Ribbons/Chunks/Publish/Preview item as an item named Debug.
  5. In the Content Editor, in the new item named Debug, in the Data section, set the value of the Header field to Debug, the Icon field to Software/16x16/debug_run.png, the Click field to system:debug, and the Tooltip field to Start the debugger.
  6. Optionally, set the icon of the new item named Debug to Software/16x16/debug_run.png.
  7. In the Sitecore Desktop, use the database icon to select the Master database.
  8. Open the Content Editor, navigate to any item with layout details, click the Publish tab, and then in the Publish group, click the Debug command.

This procedure overides an existing system command to operate at the item level. After step 2, the default Debug command on the Sitecore menu will take you to the Master database instead of the publishing target database (Web).

Download the prototype code.