Create custom menu item types
mainYou can extend the menu builder functionality by creating custom menu item types.
- Create a class that extends
Outl1ne\MenuBuilder\MenuItemTypes\BaseMenuItemType. - Implement the required methods to define how the link behaves, what fields it has, and how it displays.
- Register the class in
config/nova-menu.phpunder themenu_item_typeskey.
Required Methods to Overwrite:
getIdentifier(): Returns a unique string for the link type (e.g., 'page').getName(): Returns the display name for the type in the CMS dropdown.getOptions($locale): Returns a map of[key => value]for selection dropdowns.getDisplayValue($value, ?array $data, $locale): Returns the subtitle shown in the menu items list.getEnabledValue($value, ?array $data, $locale): Returns the enabled state.getValue($value, ?array $data, $locale): Returns the link value used on the front-end.getFields(): Returns the array of Nova fields for the resource.getRules(): Returns the validation rules for the resource.getData($data = null): Returns the data object used for front-end parsing.
// in config/nova-menu.php
return [
// ...
'menu_item_types' => [
\App\MenuItemTypes\CustomMenuItemType::class,
],
// ...
];