[Templates] How to get the current working directory?
Andy Wardley
abw at wardley.org
Sat Dec 29 08:25:21 GMT 2007
Damian Nadales wrote:
> In order to create the navigation bar, I need for each file to get the
> directory where that file is located. Is there a way of doing this using the
> template toolkit (I mean, without writing any perl code:) )?
Hi Damian,
The 'template.name' variable holds the path to the main page template
(relative to the INCLUDE_PATH).
So to get the directory you can do something like this:
[% dir = template.name.remove('/[^/]*$') %]
For example, if template.name is 'path/to/template.html' then you'll
end up with dir set to 'path/to'.
HTH
A
More information about the templates
mailing list