|There's more than one way to do things|
Template Toolkit Questionby Perobl (Beadle)
|on May 19, 2010 at 20:27 UTC||Need Help??|
Perobl has asked for the
wisdom of the Perl Monks concerning the following question:
I am a TT2 newbie. I'm using TT2 to create dynamic web pages using CGI Perl. I have set up a simple site to test my configuration running locally on Apache2. For the most part, everything is working great.
However, my images and external CSS files can't be accessed by my dynamic pages. I have my image files saved to assets/images inside my site's root directory: /Users/mysilmaril/Sites/WIW/assets/images
Likewise, my CSS file is saved to /Users/mysilmaril/Sites/WIW/css
This is all very standard stuff. When I access my CGI script from an HTML page (via a form) it utilizes TT2 to generate a wrapper and then it generates some simple text inside the [% content %] directive. This part is working great.
The images and external CSS can't be found because the dynamic page is being generated by the CGI script in the cgi-bin directory. I could hard code relative paths into my wrapper to solve this problem, but this is not an idea solution for me.
I'm sure there is a way to solve this problem through TT2's configuration, but I can't figure out how to do it. I'm pasting my test CGI script below:
My template file:
My wrapper is s standard HTML page (header, footer). I'll paste the HTML for my CSS here as an example:
If I change href="wiw.css" to href="../css/wiw.css" it will load fine, but this is what I want to avoid doing. Can I configure this in TT2? Thanks!