This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
mcustiel
Hi.
I am trying to have a static menu where users can specify some custom data when adding a menu item. Right now I can add elements to the viewbag by editing ~/plugins/rainlab/pages/classes/menuitem/fields.yaml
file, but I would like to do this from my own plugin to avoid overwriting if static pages plugin is updated.
Is there some way to extend the static menu item editor to have more fields or more items in the viewbag?
Thank you very much!
Crazymodder
Hi, this documented in StaticPages Plugin.
In your plugin.php you can add this:
Event::listen('backend.form.extendFields', function ($widget) {
if (
!$widget->getController() instanceof \RainLab\Pages\Controllers\Index ||
!$widget->model instanceof \RainLab\Pages\Classes\MenuItem
) {
return;
}
$widget->addTabFields([
'viewBag[featured]' => [
'tab' => 'Display',
'label' => 'Featured',
'comment' => 'Mark this menu item as featured',
'type' => 'checkbox'
]
]);
});
1-3 of 3