如何向Mezzanine添加自定义模板页面?

7

我已经玩了几天的mezzanine,一直在关注这个博客,对我非常有帮助。

现在我需要创建一堆基于自定义模板的页面。我的自定义模板叫做content.html

我已经将它放在myProject > myApp/theme文件夹 > templates > pages > content.html中,但是当我查看管理控制台时,下拉菜单中没有内容。

我该如何让mezzanine将我的content.html页面识别为一个模板?

2个回答

5

content.html不会自动显示在您网站的下拉菜单中。

您需要进入管理站点,并明确声明一个页面我的内容,在那里您希望content.html出现在您的页面层次结构中。

为了让 Mezzanine 匹配这两个(即模板content.html和管理页面我的内容):

  1. Either my content's Title field (in admin site) should be content,
  2. Or, URL field (in the meta data section of my content) should be content (if you decide the title will not be content),
  3. Or, if you want content.html to have a custom slug, say nicecontent, then fill URL field with nicecontent and add to url.py a pattern for content.html with a matching slug, so:

    url("^nicecontent/$", direct_to_template, {"template": "path/to/content.html"}, name="name_for_content").
    

3

Mezzanine使用一种查找模板名称的方法,从最广泛的("page.html",所有其他模板也都扩展了它),到根据其内容类型命名的模板(richtextpage.html、gallery.html等),再到最细粒度的级别,即与单个页面的url/slug匹配的模板。

这些都在文档中有详细说明:

http://mezzanine.jupo.org/docs/content-architecture.html#page-templates

听起来你可能在寻找“page.html”,但从你的问题中并不清楚。

失效链接:https://mezzanine.readthedocs.io/en/latest/content-architecture.html#page-templates - ken

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接