如何从Wagtail更改侧边栏? [英] How can I change the sidebar from Wagtail?

查看:93
本文介绍了如何从Wagtail更改侧边栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照Wagtail文档创建导航,但是建议根据片段使用,因此我想将侧边栏更改为显示导航或菜单而不是片段,那可能吗?

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?

但是当我使用文档建议的侧边栏更改时

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

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

因此会引发AttributeError:

So it raises a AttributeError:

推荐答案

sidebar_content_panels 代码不相关在这里-它演示了如果页面包含要分开的主要内容和侧边栏内容,则如何向页面编辑器添加额外的标签。与Wagtail管理员中的侧边栏菜单无关。

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.

可以使用 register_admin_menu_item 钩子( http:/ /docs.wagtail.io/zh-CN/v1.0/reference/hooks.html#register-admin-menu-item ),但这不支持编辑现有项,因此不可能更改代码段菜单的标签。但是,您可以查看 wagtailmodeladmin包 https://github.com/ababic/wagtailmodeladmin -这样,您就可以设置与代码段编辑器一样工作的管理区域,但是该管理区域位于菜单的顶层。

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.

这篇关于如何从Wagtail更改侧边栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆