How to add a custom template page to mezzanine?

倾然丶 夕夏残阳落幕 提交于 2019-11-30 04:55:35

问题


I've been playing around with mezzanine for a couple days and I've been following this blog, which has been very helpful.

I'm now at the point where I need to make a bunch of pages that need to be based off of a custom template. My custom template is called content.html

I've put it in myProject > myApp/theme folder > templates > pages > content.html but when I look in the admin console, I don't see content in the drop down menu.

How do I get mezzanine to recognize my content.html page as a template?


回答1:


content.html will not automatically appear in your site's drop down menu.

You need to go to the admin site and explicitly declare a page my content where you would like content.html to appear in your page hierarchy.

For mezzanine to match the two (i.e. template content.html and admin page my content):

  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").
    



回答2:


There's a method Mezzanine uses for looking up template names, from the broadest ("page.html", which all other templates also extend), to templates named for their content types (richtextpage.html, gallery.html, etc), down to the most granular level, which is templates matching the url/slug of individual pages.

This is all covered in the documentation:

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

It sounds like you might be looking for "page.html", but it's not clear from your question.



来源:https://stackoverflow.com/questions/16841690/how-to-add-a-custom-template-page-to-mezzanine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!