It's my first shot at creating a command template. Basically I want the command to trigger when I create a content item based on a specific branch. I've tried to follow the guidelines in Sitecore's "Data Definition Cookbook", but I simply can't get it to work.
Here's exactly what I've done (in Sitecore 7.1):
I've created a Command Template like this:
namespace MyApp.Commands
{
public class MyCommand : Sitecore.Shell.Framework.Commands.Command
{
public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context)
{
// do stuff
}
}
}
I've registered it as a command in the Commands.config like this:
<command name="mynamespace:mycategory:mycommand" type="MyApp.Commands.MyCommand,MyApp"/>
In Sitecore I've created a command template called MyCommandTemplate based on the "/sitecore/templates/System/Branches/Command Template" template and set the Command field to:
mynamespace:mycategory:mycommand(id=$ParentID)
Additionally I've created a data template called MyTemplate and in "__Standard Values" I've added MyCommandTemplate to Insert Options.
For MyTemplate I've created a branch called MyBranch based on the "/sitecore/templates/System/Branches/Branch" branch template, and on the branch's $name sub item I've checked that it does indeed have MyCommandTemplate set in Insert Options.
However, when I create a content item based on MyBranch, then the Execute method in MyCommand is not triggered (code is not run and I can't hit it with debugger in Visual Studio).
Does anyone have an idea what I'm doing wrong?