Sitefinity CMS enables you to provide a custom set of commands that are displayed in the More menu of an MVC widget while in edit mode. You can customize the commands in this menu depending on the current widget and the its current state. For example, a shared content block can render different commands than an unshared one.
You can customize all aspects of adding custom command, for example, what type of window you open when you click an item, or a command, from the menu.
To provide a custom set of commands for a widget, the controller of the widget must implement the IHasEditCommands interface. Thus, you can add to or replace the collection of commands with a custom set of commands depending on your requirements. By default, the command collection is empty. If the widget does not inherit the IHasEditCommands interface, the default commands are displayed:
IHasEditCommands
PREREQUISITES: You created a new widget. For details how to do this, see Create widgets.
In this example, you add custom command to a Message widget. To do this:
MessageWidgetController.cs
MessageWidgetController
Commands
CustomComand
NOTE: You need to also add the default commands for Delete, Duplicate, and Permissions. Otherwise, you will just see the custom commands.
Delete
Duplicate
Permissions
Index
MessageWidgetController.
Use the following code sample:
JSON
As a result, you can see the new command in the Message widget’s More menu.
For a more comprehensive example, see the ContentBlockController class in the GitHub repository.
ContentBlockController
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important