- Add Custom Command item definition in the Core database
- Create a new Chunk item
- Create a new Custom Command item (Based on the “Small Button” template)
- Add the Custom Command Class Code
- Add A Custom Command definition in the Command.config file
Add Custom Command Item definition in the Core database
First, navigate to the Core Database and locate the Sitecore app you want to enhance. In this case, I want to enhance the User Manager located at “/Sitecore/content/Applications/Security/User Manager“.After creating the custom chunk (or navigated to an existing chunk) , you can create your Custom Command. Select the “/System/Ribbon/Small Button” template:
The Custom Command definition item contains seven fields. Most important is:
- “Header”: The name of the custom command displayed in the chunk of the Sitecore application).
- Click”: Bind your Custom Command Item definition to your Custom Command Class Code. In this case “MyCommands:Refresh”.
- “Icon”: The icon to be displayed.
The Custom Command Class code
Now it is time for do the coding. In the case of my Refresh command I only need the following code:Adding the Custom Command definition to Command.config
The final step is to create the custom command definition in the “/App_Config/Commands.config” file, or even better into an include file places at “/App_Config/Include/MyProject.Command.config”:Validate The Refresh Command in the User Manager
Open your User Manager and select your Custom Command “Refresh”:Furthermore
You can add
parameters to you custom command:
In this case, Sitecore will pass the ID of the selected item to the command.
No comments:
Post a Comment