On Thu, Jul 17, 2008 at 8:04 AM, 3xM <[EMAIL PROTECTED]> wrote:
> I already tried loading templates a la
>
> '%s/name_of_template.html' % channel_template_folder
>
> but the result is that it when the template includes other templates,
> it will look for it in the same folder, not doing the fallback thing
> to the main generic template folder (as it is looking for something in
> a subfolder with the name of the value of channel_template_folder).
>
> Does it make sense?

Right, the includes will be relative to TEMPLATE_DIRS.

> I'll try to illustrate the current template structure to clarify:
>
> .../templates
>    part_1.html
>    part_2.html
>    /channel_a
>        part_1.html
>    /channel_b
>        part_2.html
>
> (I hope the identation in the above doesn't get ignored as whitespace)
>
> So, normally I load e.g. 'part_1.html' which, somewhere in it,
> includes 'part_2.html'. That works just fine.
>
> But for Channel A I used to load 'channel_a/part_1.html', which will
> also include 'part_2.html'. But now the template system will look for
> a file called 'channel_a/part_2.html' which doesn't exist.

The template system will only look for "part_2.html" under "channel_a"
if "channel_a" is in your TEMPLATE_DIRS.

> And for Channel B, where I only want 'part_2.html' to be different
> from the generic, I can't get it to work without adding
> 'templates/channel_b' to TEMPLATE_DIRS. A "solution" is to copy all
> templates each time I want to make differences, but that seems quite
> stupid to me.

Or you could leave TEMPLATE_DIRS alone and use this in "channel_b/part_1.html":

  {% include "channel_b/part_2.html" %}

> So what I want is to temporarily add 'templates/channel_b' to
> TEMPLATE_DIRS for requests for playlists from Channel B. Is it somehow
> possible?

But is it a good idea?

If it turns out that the only solution for your problem is to have
some fallback mechanism when including templates, you could always
write a template tag to do just that.  And maybe you can solve it
using some combination of template inheritance, inclusion and
select_template.


Arien

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to