How can I change the sidebar from Wagtail?
Asked Answered
R

3

5

I'm following the Wagtail docs to create a navigation, but it's recommend to use based on 'Snippets', so I would like to change the sidebar to show "Navigation" or "Menu" instead of 'Snippets', is that possible? enter image description here

But when I use just like the docs recommends for sidebar changes:

sidebar_content_panels = [
    SnippetChooserPanel('advert', Advert),
    InlinePanel('related_links', label="Related links"),
]

So it raises a AttributeError: enter image description here

Ruffina answered 5/8, 2015 at 2:20 Comment(0)
Z
8

The sidebar_content_panels code is not relevant here - it demonstrates how you would add an extra tab to the page editor, if your pages contained "main content" and "sidebar content" that you wanted to keep separate. It's nothing to do with the sidebar menu in the Wagtail admin.

It's possible to add new items to the admin menu using the register_admin_menu_item hook (http://docs.wagtail.io/en/v1.0/reference/hooks.html#register-admin-menu-item), but this doesn't support editing an existing item, so it won't be possible to change the label of the 'snippets' menu. However, you could look at the 'wagtailmodeladmin' package https://github.com/ababic/wagtailmodeladmin - this allows you to set up admin areas that work like the snippet editor, but exist at the top level of the menu.

Zygote answered 5/8, 2015 at 12:17 Comment(0)
S
2

I dont know if it was at the time, but now you can change the name of the sidebar navigation without the need to move to ModelAdmin. This is done by using the "construct_main_menu" hook and by adding the snippet below to model admin like so:

@hooks.register("construct_main_menu")
def change_snippet_name(request, menu_items):
    for item in menu_items:
        if item.__class__.__name__ == "SnippetsMenuItem":
            item.label = "Contact persons"
Scant answered 13/12, 2019 at 8:14 Comment(0)
C
0

Wagtail allows you to create custom menu on admin panel sidebar by extending wagtail's ModelAdmin

you can check the example and documentation for new v2.4 here.

https://docs.wagtail.io/en/v2.4/reference/contrib/modeladmin/index.html#summary-of-features

Contrabass answered 18/1, 2019 at 11:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.