Yeah I was going to post a sample if that's what he said next :) Here is another sample in addition to the link above .. on how to pass the menu code via context processors:
In your settings.py file ... Find the line that says (there may be more in there depending on your setup): TEMPLATE_CONTEXT_PROCESSORS = ("django.core.context_processors.request",) Change it to something like this: TEMPLATE_CONTEXT_PROCESSORS = ('yourproject.yourapp.somepythonfile.menu',"django.core.context_processors.request",) Then under in your python code create a menu function which corresponds to the above: def menu(request): return {'menu': "some html code for the menu"} Then when calling up each of your views add (context_instance=RequestContext(request)) when calling render_to_response: return render_to_response('somefile.html', {'someothervariableyouyoumightwant':value},context_instance=RequestContext(request)) Now you can access this via {{ menu }} in any of your templates. On Jul 28, 2:26 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > I could be wrong, but I think the problem he's having is having to > specify the menu variable in the context for every view, not the > template end of it... > > To fix that, you will want to check out context > processors:http://www.djangoproject.com/documentation/templates_python/#subclass... > > On Jul 28, 10:30 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > Why not have a base template that contains the menu variable ( I put > > mine in a session variable accessible to the templates named menu ), > > then have all of your other templates extend from that template? > > > In base.html: > > > <head>your header code</head> > > <body> > > {% block menu %} > > {{ menu }} > > {% endblock%} > > > {% block content %}{% endblock %} > > </body> > > > Then in your other templates: > > {% extends "base.html" %} > > > {% block content %} > > content for your html specific page here > > {% endblock %} > > > On Jul 28, 1:13 pm, Eloff <[EMAIL PROTECTED]> wrote: > > > > I've got a nav.html template that does the menu on every page. The > > > only trouble is I have to store the menu items in a global variable > > > and pass it to the page template in every view. Is there any way to > > > make a view for the nav.html template (which is included in all the > > > page templates)? I imagine it could be done with SSI but I don't want > > > to go that route unless I have no other option. > > > > Thanks, > > > -Dan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---