On Tue, 2007-02-13 at 17:29 +1100, Michael Lake wrote:
> Hi all
>
> Is there a way for a template file to know its name? The reason is that I
> have a
> template file base.html which is placed at the beginning of each HTML file
> and it
> contains a link to the help page. This will appear on each page and works
> fine.
>
> However I don't want the help link to appear on the help page itself so I was
> wanting
> to have something like this in base.html
>
> {% if template_name == help.html %}
> <!-- dont show any link for help -->
> {% else %}
> <a href="/help">Help</a>
> {% endif %}
>
> where template_name or something is the name of the current template file
> being rendered.
There isn't any way to do this built into Django. It may not always make
sense, either, since a template could just be a string (hence have no
name).
Looking through some code I have written, I found a case where I was
doing something like you are and I am just passing in a "no_display"
variable in the context on the pages that shouldn't have a link like
this. I test to see if no_display is false before trying to display the
link (in fact, in my case, it's on a help page, too).
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?hl=en
-~----------~----~----~----~------~----~------~--~---