[Templates] Beginner Question: A way around absolute paths?

Kip Lawrence kip@jkcrafts.com
Thu, 16 Oct 2003 10:00:00 -0600


Thank you for your response Axel.

My site has thousands of Virtual Hosts with more being added every day.
Each host is going to have a completely different set of template files.
Each virtual host would need a different entry in the include path
(which I am setting in httpd.conf). Is there no way to just look for
include files in the directory the template file was run in?

For instance say my httpd.conf has the following line:
TT2IncludePath    /usr/local/tt2/templates

  Also I have a virtual host www.test.com which corresponds to the
directory /home/httpd/sites/t/e/. In that directory are the files
index.tt2, header and footer.

Now if in a browser I hit www.test.com/index.tt2 I would like the script
to be able to recognize it's path and proccess the include files from
there... not from /usr/local/tt2/templates.

It would not be practical for me to add a path to TT2IncludePath for
each new virtual host.

I hope I'm making sense. Anyways, any ideas would be appreciated.

Thanks,
Kip



On Thu, 2003-10-16 at 05:04, Axel Gerstmair wrote:
> Hello Kip!
> 
> On Thursday, October 16, 2003 at 08:41, Kip Lawrence wrote:
> > [...] I am trying to decide how best to write my templates.
> > Currently I have three files... header, footer, and index.tt2. The
> > extension .tt2 is routed to Apache::Template.
> 
> > In the Apache error_log I see the following:
> 
> > ----------
> > [error] access to
> > /home/httpd/sites/d/e/devstore.pmgmentors.com/index.tt2 failed for
> > 000.000.000.000, reason: file error - header: not found
> > ----------
> 
> Use include paths to specify where your template files are located.
> 
> When you are using Apache::Template, you can specify one or more
> include paths in your httpd.conf via the TT2IncludePath directive,
> e.g.
>     TT2IncludePath    /usr/local/tt2/templates
> 
> When you are using Template Toolkit directly, you can specify the
> include paths at creation of the template object, e.g.
> 
>     my $template = Template->new({
>         INCLUDE_PATH => '/usr/local/tt2/templates',
>     });
> 
> Please have a look at the Perl documentation of Apache::Template
> [1] and Template Toolkit [2], where things are explained in more
> detail and examples are given.
> 
> Best regards,
> Axel
> 
> [1] perldoc Apache::Template -or-
>     http://www.template-toolkit.org/download/Apache-Template-0.08/README
> [2] perldoc Template::Manual::Config -or-
>     http://www.template-toolkit.org/docs/default/Manual/Config.html
> 
> 
> _______________________________________________
> templates mailing list
> templates@template-toolkit.org
> http://lists.template-toolkit.org/mailman/listinfo/templates