On Fri, 2006-08-18 at 12:14 +0900, Sean Schertell wrote:
> Hi folks,
> 
> Okay, so I got my little staticpages app working (thanks adrian), and  
> now I can happily throw sometemplate.html in my templates/ directory  
> and I can view the page at mysite/sometemplate. Great! And it extends  
> my base.html template too so all my header/footer stuff is DRY. Hooray!
> 
> But what about the bits that change from page to page, like the page  
> title, or the body "id" attribute, html metatags, etc. Is there any  
> convenient way to pass those values in from the child template? Right  
> now I'm using blocks in my base.html like this:
> 
> <body id="{% block page_id %}{% endblock %}">
[...]

> Is there any way then to more elegantly set the page title, body id,  
> etc without using blocks and without writing view methods?

You have to do it the way you are doing it now. Template inheritance
only allows you to override blocks, not set variables in the context.

Remember that you are in a slightly fringe area. Normally, if you were
having per-page id settings, you would creating the pages through views
and you would pass in the appropriate id value(s). If you don't want to
have views and just have templates, then you have to do it via blocks.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to