【问题标题】:How to add a custom template page to mezzanine?如何将自定义模板页面添加到夹层?
【发布时间】:2013-05-26 08:30:27
【问题描述】:

我已经玩了几天夹层,我一直在关注这个blog,这非常有帮助。

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

我已将其放入 myProject > myApp/theme folder > templates > pages > content.html,但是当我查看管理控制台时,我在下拉菜单中看不到内容。

如何让夹层将我的content.html 页面识别为模板?

【问题讨论】:

    标签: django templates django-cms mezzanine


    【解决方案1】:

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

    您需要转到管理站点并明确声明一个页面my content,您希望content.html 出现在您的页面层次结构中。

    让夹层匹配两者(即模板content.html 和管理页面my content):

    1. my content 的标题字段(在管理站点中)应为 content
    2. 或者,URL 字段(在my content 的元数据部分中)应该是content(如果您决定标题不是content),
    3. 或者,如果您希望 content.html 有一个自定义 slug,比如 nicecontent,然后用 nicecontent 填充 URL 字段,并在 url.py 中添加一个带有匹配 slug 的 content.html 模式,所以:

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

    【讨论】:

      【解决方案2】:

      Mezzanine 使用一种方法来查找模板名称,从最广泛的(“page.html”,所有其他模板也扩展)到以其内容类型命名的模板(richtextpage.html、gallery.html 等) ,细化到最细化的级别,即匹配单个页面的 url/slug 的模板。

      这些都包含在文档中:

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

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

      【讨论】:

        猜你喜欢
        • 2021-04-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-30
        相关资源
        最近更新 更多