是否可以在非 CMS 应用程序中显示 Django-CMS 菜单?

发布于 2024-10-14 15:53:17 字数 623 浏览 7 评论 0原文

在 Django 项目中,我有 Django-CMS 和另一个应用程序(我们称之为“应用程序 B”)。我希望这两个应用程序都有一组一致的菜单。我已使用 menu_pool.register_menu 添加了新项目。 此页面

请注意,菜单最初是独立于应用程序实现的,因此位于菜单应用程序中,而不是“普通”cms

,因此我希望我可以在“应用程序 B”的模板中编写与内容管理系统。我的“App B”模板和 CMS 模板中都有这个:

<ul>{% show_menu 0 100 0 1  %}</ul>

在 CMS 中它可以工作,显示完整的菜单。在“App B”中,它只是呈现空白:

<ul></ul>

除非必须,否则我不想创建插件或应用程序挂钩。我必须这样做吗?

编辑:我已经用 App-Hook 尝试过,但它仍然不起作用。

In Django project I have Django-CMS and another application (let's call it "App B"). I want a consistent set of menus across both apps. I have added the new items with menu_pool.register_menu. This page says

Please note that menus were originally implemented to be application-independant and as such, live in the menus application instead of the “normal” cms

so I would expect that I can write the same menu tag in the template for "App B" as for CMS. I have this in both my "App B" template and my CMS template:

<ul>{% show_menu 0 100 0 1  %}</ul>

In the CMS it works, showing the full menu. In "App B" it just renders blank:

<ul></ul>

I don't want to have to create a plugin or app hook unless I have to. Do I have to?

EDIT: I have tried this with an App-Hook and it still doesn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

霓裳挽歌倾城醉 2024-10-21 15:53:17

有一个模板标签: show_menu_below_id

There is a template tag for that: show_menu_below_id

千と千尋 2024-10-21 15:53:17

进一步引用:

注意

像这样附加的所有视图都必须返回 RequestContext 实例,而不是默认的 Context 实例。

我只需将 context_instance=RequestContext(request) 添加到我的 render_to_response 中。

To further quote:

Note

All views that are attached like this must return a RequestContext instance instead of the default Context instance.

I just had to add context_instance=RequestContext(request) to my render_to_responses.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文