views:

15

answers:

1

I am writing a blog application as a part of a larger website. I want to have a main (static) nav bar for the site navigation, but I want to have a sub nav that allows the user to filter the blog posts by other criteria when viewing the blog.

Something like

Latest | Popular | Category | Author | Date | Tag
                 |-> News   | Dave   | Year | X
                 |-> Django | Peter  | Month| Y 
                 |-> etc.   | etc.   | etc. | etc.

where the 2nd level of the nav is automatically generated from the categorie, tag, user etc.

I know I could pass the model objects as a part of the context in the views/generic views, but this seems to be a bad option, as I'd be repeating myself for every view in the blog application. Surely there is some easier way of doing this?

+1  A: 

You could have a look at zinnia blog which provides the functionality you need. It also integrates very well with django-cms and provides together with the cms' menus app EXACTLY the menu structure you desire! If you do not want to use it, have a look at its template tags to see how the navigation you desire is generated!

lazerscience
Thanks, that looks like exactly what I want. I wasn't sure to what extent template tags should be handling logic etc. I also found http://www.mechanicalgirl.com/view/custom-template-tags-in-django/ which is exactly what I need
pastylegs
Well as i mentioned, if you need an app to administrate your navigation, have a look at django-cms as well...
lazerscience
http://www.b-list.org/weblog/2006/jun/07/django-tips-write-better-template-tags/ another description of the functionality I want for anyone interested
pastylegs