Reputation: 3289
I am building custom AdminModels based on Wagtail Snippets and have a custom menu in the AdminPanel for my models. How do I hide/remove the Snippet selection from AdminPanel without disabling? Thank you.
Upvotes: 6
Views: 2077
Reputation: 113
Since item.name
in menu_items
can be blank, better solution is:
from wagtail.snippets.wagtail_hooks import SnippetsMenuItem
@hooks.register('construct_main_menu')
def hide_snippets_menu_item(request, menu_items):
menu_items[:] = [item for item in menu_items if not isinstance(item, SnippetsMenuItem)]
Upvotes: 9
Reputation: 348
Put the following hook into wagtail_hooks.py file of your Wagtail CMS app:
from wagtail.wagtailcore import hooks
@hooks.register('construct_main_menu')
def hide_snippets_menu_item(request, menu_items):
menu_items[:] = [item for item in menu_items if item.name != 'snippets']
And you're basically done! You can use this approach to hide any item from the admin menu.
I described it recently on my blog: http://timonweb.com/posts/how-to-remove-snippets-menu-item-from-wagtail-cms-admin-menu/
Upvotes: 7