Hi Sean,

That sounds like what I was looking for. Thank you very much!
Now to figure out how to use them.. :-)

Dan.

2008/6/5  <[EMAIL PROTECTED]>:
>
> If you generate the data required for Block A in a context processor, then
> it will be globally available, and the views/apps that fill in block B can
> remain completely ignorant of them.
>
> See
>
> http://www.djangoproject.com/documentation/templates_python/#writing-your-own-context-processors
>
> A combination of a context processor and the common template being
> included in the base.html sounds like it would do the job for you.
>
> Sean
>
>
>
>
>>
>> Hi,
>>
>> Thanks for the quick reply.
>> I'll try to explain why I don't think that will work and hopefully you
>> will tell me I'm wrong ;-)
>>
>> Lets say I have a template, base.html that looks something like this:
>>
>> <whatever html>
>> {% block A %}{% endblock %}
>> {% block B %}{% endblock %}
>> more html
>>
>> Block A contains, lets say, news items. Block B contains my page. B is
>> filled in by various different apps (probably by displaying a template
>> which includes base.html), but A should always be filled in by the
>> same app, regardless of the app controlling B (preferably from its own
>> template). The two apps should not know or care about each other
>> (except, obviously, if the news is specific to the page, but lets
>> ignore that for now).
>>
>> When I have a view in an app, I'd normally make it display some
>> template, which would in turn include another template, all the way
>> down to the base template. But, what I want to do seems to have two
>> root templates which include the base template... am I missing
>> something or thinking about the problem wrong?
>>
>> I hope people understand :-P
>>
>> Thanks!
>> Dan.
>>
>> 2008/6/5 Bartosz Ptaszynski <[EMAIL PROTECTED]>:
>>>
>>> If you want something to be displayed on all of your pages why not
>>> adding it to the master template that you extend later on with
>>> specific templates.
>>> You could also use the {% include %} tag to include the template in
>>> other template.
>>> Remember that you always work with the context provided to the
>>> template by the current view. So for example when you have two views
>>> using different templates, and both include your extra template, you
>>> will have to make sure that you provide all the data the extra
>>> template needs to display properly to both views.
>>> If you are using generic views you can use extra_content dictionary to
>>> pass any extra data your template may need.
>>>
>>> I hope I've managed to explain this...
>>>
>>> ---
>>> Bart
>>>
>>> On 5 Jun 2008, at 17:39, Daniel Kersten wrote:
>>>
>>>>
>>>> Hi all,
>>>>
>>>> If I have a django app, for example, some sort of news feed, or maybe
>>>> adds - whatever, which I want to display on all (or most) of my pages
>>>> (handled by different views) and this app has it's own template to
>>>> handle how it's displayed, how do I connect it up to the app(s) that
>>>> handle the pages?
>>>>
>>>> My instinct tells me there must be a better way than to manually call
>>>> it from each of my views, seems like bad code duplication to me, but I
>>>> don't really know how one would normally handle this.
>>>> Also, let's say that this app should behave differently depending on
>>>> which page the user is currently on. (eg, news or adds related only to
>>>> that specific page - the code is the exact same, but different data is
>>>> fetched from the database).
>>>>
>>>> Thanks in advance for any help or tips!!
>>>> Dan.
>>>>
>>>> --
>>>> Daniel Kersten.
>>>> Leveraging dynamic paradigms since the synergies of 1985.
>>>>
>>>> >
>>>
>>>
>>> >
>>>
>>
>>
>>
>> --
>> Daniel Kersten.
>> Leveraging dynamic paradigms since the synergies of 1985.
>>
>> >
>>
>
>
>
> >
>



-- 
Daniel Kersten.
Leveraging dynamic paradigms since the synergies of 1985.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Python Ireland" 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.ie/group/pythonireland?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to