Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customizing Mezzanine

I've been researching Mezzanine for some time now, but I haven't found much of tutorials beyond basic installation. Mezzanine docs contain information on how to customize Page models and adding new content types.

However, what I want to do is utilise existing content types (pages, blog posts) in different ways.

For example, I want to have custom "blog listing" page beyond basic default blog listing.

How do I even create that - second - blog page in the admin? How do I set it's template to my, custom template without touching default blog list template?

How do I therefore have 2 different blog listing pages?

like image 728
tonino.j Avatar asked Jan 19 '13 20:01

tonino.j


1 Answers

Use the mezzanine.blog.models.BlogCategory model for your different blog lists. If you are not happy with 'category/' being in the path, you can copy and modify (below) the mezzanine.blog.urls to your project urls.py.

url("^%s(?P<category>.*)%s$" % _slashes,
    "mezzanine.blog.views.blog_post_list",
    name="blog_post_list_category")

To create category templates, take a look at the blog_post_list view and you will see:

templates.append(u"blog/blog_post_list_%s.html" %
                          unicode(category.slug))

To add a template for category "Foo", copy mezzanine/blog/templates/blog_post_list.html to your project templates/blog/blog_post_list_foo.html. The new template will render if you navigate to /blog/foo/.

like image 55
ken Avatar answered Sep 24 '22 15:09

ken