Redirect homepage template to customized html instead of pages/index.html

192 views
Skip to first unread message

Wesley

unread,
May 13, 2014, 3:09:46 AM5/13/14
to mezzani...@googlegroups.com
Hi all,
  I am learning to customize homepage theme according to http://bitofpixels.com/blog/mezzatheming-part-2-the-homepage/
Here I hit a question that, homepage always use pages/index.html, actually, I have a homepage.html extends pages/index.html.

So, how to change the template name for the new added homepage(subclass Page just as that artical said).

Thanks.
Wesley

Josh Cartmell

unread,
May 13, 2014, 9:44:09 AM5/13/14
to mezzani...@googlegroups.com
Hey Wesley, making the homepage a page is a bit of a special case in Mezzanine and I think it always and only looks for pages/index.html.  I could be wrong about that.

I actually wrote the referenced article and the reason I always have pages/index.html subclass pages/homepage.html is so that if someone creates another "homepage" page type that isn't actually the homepage it will still pick up the correct template.


--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

JoshJ

unread,
May 22, 2014, 2:07:08 PM5/22/14
to mezzani...@googlegroups.com
Hi Wesley,

What would be the reason behind keeping Mezzanines index.html and having your own homepage.html extend it?

What I mean is, if you copy the index.html from the Mezzanine library and place it in your local templates folder you can override Mezzanines index.html and customize it however you like.  So that whenever Mezzanine looks for index.html it will pull up your index.html template.  Their index is more of a starting point and not a solution so feel free to cut it up however you'd like :)

As an example I've set the templates folder for my project to be (via settings.py) to be the 'templates' folder from the root of my project.
Ex: TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, "templates"),)

So if I place index.html in that folder Mezzanine loads that file as my index.  I can put whatever I want in the file and mezzanine will use it as the index.

Josh Cartmell

unread,
May 22, 2014, 3:16:12 PM5/22/14
to mezzani...@googlegroups.com
Hey Josh, I think his reasoning was to make the homepage a backend editable page in which case there could be more than one of them.  The ones that don't have a slug of / would look for pages/homepage.html.  By extending index.html (and more likely pages/index.html) you can make them all look the same without having duplicate templates


--

Josh Johnson

unread,
May 22, 2014, 3:29:40 PM5/22/14
to mezzani...@googlegroups.com
Ah'!

Thanks Josh, probably better for him to extend base.html in that case no? Index.html simply extends it and inserts content into its 'body' block.


--
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/Cekm4a0K7o8/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.



--


Josh Cartmell

unread,
May 22, 2014, 4:45:06 PM5/22/14
to mezzani...@googlegroups.com
Well, if you are making the homepage an editable page in the page tree you have to modify your projects urls.py and it will specifically look for pages/index.html for the home page.  I usually make pages/homepage.html (to match the name of the model) and then have pages/index.html only contain:

{% extends "pages/homepage.html" %}

That way pages/index.html gets the styling from pages/homepage.html and any other instance of a HomePage page will pick up styling from pages/homepage.html making it consistent.

pages/homepage.html would be something like:

{% extend "pages/page.html" %}

{% block main %}

{{ content goes here }}

{% endblock %}

Josh Johnson

unread,
May 22, 2014, 5:31:58 PM5/22/14
to mezzani...@googlegroups.com
Ah' - I just pulled up the library, I see what you're saying now.  

When I did my site I didn't want the index page editable so I just overrode the main index.html page and used base.html instead of pages/page.html
Looks like the extension hierarchy goes base.html -> page.html -> ricktextpage.html -> index.html

Well at least I know how to do it if I ever want to edit it via the admin page! Thanks lol

Wesley

unread,
May 22, 2014, 9:34:46 PM5/22/14
to mezzani...@googlegroups.com
Well, actually, I did that with the way Josh Cartmell mentioned.
Thanks a lot:-)

Wesley

在 2014年5月13日星期二UTC+8下午3时09分46秒,Wesley写道:
Reply all
Reply to author
Forward
0 new messages