You can customize the menus of widget fields, widgets, and lists to provide additional functionality to editors, e.g. splitting or joining widgets, translating or converting their content, etc. See below for a fully functional example of how to insert an item into widget menus.
For accessing the menu object of a DOM element that represents a piece of CMS content, scrivito("menu")
is available. Currently, this only applies to DOM elements that represent either widgets (the element has a data-scrivito-widget-obj-class
attribute) or widget fields (the data-scrivito-field-type
equals widgetlist
). The menu object has several methods.
Adding new items
Use add
to create new menu items: