Closed spacebeers closed 2 years ago
No worries, can you share the code that you are using to extend the types?
@daftspunk So the site's all made using the builder so I've got no idea where to look for that. Any clues very welcome
Alright, can you walk me through the steps you took using Builder to arrive at this point? It will help to recreate the problem on our end.
Thanks. I've worked part of it out and that's mainly that the previous developer had changed the following inside the plugin:
This had been changed to include the Bootstrap menu classes so that's one mystery solved.
As for the rest of it - all I've done is upgraded October core and then the plugins. This wiped out the styling as mentioned about but in the admin I still get the "Undefined index: discover" on line 113
when trying to update the menu.
There are two types from Builder that I assume were appearing in the Types dropdown previously (Discover and Product). Is there any documentation on how to add types to the dropdown?
Ok, modifying core files will have this effect. Here is the docs on registering custom menu types (Discover and Product):
Plugins can extend the Static Pages plugin with new menu item types. Please refer to the Blog plugin for the integration example. New item types are registered with the API events triggered by the Static Pages plugin. The event handlers should be defined in the boot()
method of the plugin registration file. There are three events that should be handled in the plugin.
pages.menuitem.listType
event handler should return a list of new menu item types supported by the plugin.pages.menuitem.getTypeInfo
event handler returns detailed information about a menu item type.pages.menuitem.resolveItem
event handler "resolves" a menu item information and returns the actual item URL, title, an indicator whether the item is currently active, and subitems, if any.The next example shows an event handler registration code for the Blog plugin. The Blog plugin registers two item types. As you can see, the Blog plugin uses the Category class to handle the events. That's a recommended approach.
public function boot()
{
Event::listen('pages.menuitem.listTypes', function() {
return [
'blog-category'=>'Blog category',
'all-blog-categories'=>'All blog categories',
];
});
Event::listen('pages.menuitem.getTypeInfo', function($type) {
if ($type == 'blog-category' || $type == 'all-blog-categories') {
return Category::getMenuTypeInfo($type);
}
});
Event::listen('pages.menuitem.resolveItem', function($type, $item, $url, $theme) {
if ($type == 'blog-category' || $type == 'all-blog-categories') {
return Category::resolveMenuItem($item, $url, $theme);
}
});
}
Looks like they were just updating the core files! No wonder I couldn't find it. Thanks so much for your help.
Description:
I've recently managed to upgrade a mess of an October CMS site to v2 and I've got one last issue before I can release it.
The Pages plugin menu builder won't recognise my types created in the Builder plugin anymore. The UI only shows the standard list of types since the upgrade.
If it's any help I've also lost all my menu styling classes from the mark up now too.
My familiarity with the October ecosystem isn't great so any pointing in the right direction would be great.