Creating templates for custom page types anywhere in the tree

25 views
Skip to first unread message

Avery Laird

unread,
Aug 18, 2015, 8:01:38 PM8/18/15
to Mezzanine Users
Hello,

I've been creating some custom pages types, and templates to display them. I've been placing the templates in `pages/` and giving them the same name as the custom page. This works fine, except for when I place the page somewhere else in the tree. For example, if I have two custom pages (Page A and Page B) and place Page B under Page A in the page tree, the page is no longer rendered using my template. Looking at the docs, I'm not sure how to handle this. Any help would be great!

Cheers

Neum Schmickrath

unread,
Aug 19, 2015, 1:29:30 PM8/19/15
to Mezzanine Users
Let's say you created a custom page type and the model class is "Test" and then in your pages templates folder you placed your template at pages/test.html. In that case you should be able to create a "test" page anywhere in the tree and have it rendered using the test.html template assuming that your test.html template extends the page template like {% extends "pages/page.html" %}. Make sure and load mezzanine_tags and other tags in that template as needed as well. It sounds like you aren't extending the template so it's only overriding the specific page at that URL. 

Avery Laird

unread,
Aug 19, 2015, 1:36:57 PM8/19/15
to Mezzanine Users

Hi Neum,

My custom templates do extend `pages/page.html`, but for some reason are not being rendered. Do you know of any other possible reasons this could be an issue? As far as I know, if the template is named correctly, in the right directory, and extends pages/page.html, it should render properly.


--
You received this message because you are subscribed to a topic in the Google Groups "Mezzanine Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mezzanine-users/26nJSXEyxMs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Neum Schmickrath

unread,
Aug 19, 2015, 4:40:10 PM8/19/15
to Mezzanine Users
The only thing I can think of is that you possibly have a template in the sub-tree that has the same name so it's overriding the custom page's default template. For instance in your example if you placed Page B under Page A and you had a template at pages/page-a/page-b.html it's going to use that template first instead of the default template that might be at pages/page-b.html. If you add the beginning of your custom class and the URL settings of the pages you have created it would be helpful in trying to figure out what is going on.

Avery Laird

unread,
Aug 19, 2015, 4:49:34 PM8/19/15
to Mezzanine Users
Thanks so much for your help, I figured out the issue! I realized I had accidentally named one of my templates incorrectly, and it didn't match the name of the class. All seems to be working now.

Cheers!
Reply all
Reply to author
Forward
0 new messages