Re: [htmltmpl] Problem accessing directories through .tmpl files
Brought to you by:
samtregar
From: Carl F. <C.A...@du...> - 2004-11-25 09:11:18
|
Sharad, The paths to your image files (and css, js, etc) are relative to the CGI script. The folder that the .tmpl file is in is irrelevant. Also filesystem paths are irrelevant: it's the website paths you need to know. e.g. if the CGI is at "/cgi-bin/sample/display.pl" Then the image files must be somewhere inside the "htdocs" folder for the webserver to be able to serve them. So if an image is at "/images/pic.jpg", then the IMG tag source should either be: src="/images/pic.jpg" which is an 'absolute' path in relation to the web-root. or: src="../../images/pic.jpg" which is relative to the path of the CGI file. Remember, any files referenced from a webpage, such as an image or css file, must be within your htdocs folder. They aren't magically included by the CGI, they are requested by your browser, and so must be visible to the webserver. Hope this helps, Carl >>> Kasturirangan Rangaswamy <kas...@ya...> 24/11/2004 04:26:42 >>> Hi, I have a small Perl Script that calls a .tmpl file A.tmpl. This .tmpl file has two <TMPL_INCLUDE> statements that include two other files B.tmpl and C.tmpl. Files A,B and C are in the same directory. I am able to display the three of them as a single HTML file. No problems till here. Now, the B.tmpl and C.tmpl files access images stored in yet another directory (NOTE: Also tested by putting them in same directory and that is not working either!!!). Those images are not getting displayed. Below are the details (Consider ROOT=/usr/local/apache/htdocs/homepages) Main Perl Script (present in ROOT/software/cgi-bin/sample/) ----------------------------------------------------------------------- #!/usr/local/bin/perl use HTML::Template; my $template = HTML::Template->new(filename => "$ENV{DOCUMENT_ROOT}/software/html/Index.tmpl"); print "Content-Type: text/html\n\n"; print $template->output; ----------------------------------------------------------------------- Index.tmpl (present in ROOT/software/html/) ----------------------------------------------------------------------- <TMPL_INCLUDE top_screen.tmpl> <TABLE>some table items that do not refer to images/CSS and have not been included here</TABLE> <TMPL_INCLUDE bottom_screen.tmpl> ------------------------------------------------------------------------ top_screen.tmpl (present in ROOT/software/html/) ----------------------------------------------------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- saved from url=(0034)http://www.uc.edu/softwareinstall/ --> <!--- top header included in another file---><HTML><HEAD><TITLE>UCit - Software Distribution</TITLE> <META http-equiv=Content-Type content="text/html; charset=windows-1252"><LINK href="main.css" rel=stylesheet> <META content="MSHTML 6.00.2800.1476" name=GENERATOR></HEAD> <BODY leftMargin=0 topMargin=0 marginheight="0" marginwidth="0"> <TABLE cellSpacing=0 cellPadding=0 width=800 border=0> <TBODY> <TR> <TD colspan=3><IMG alt="" src="banner_software.gif" border=0><IMG alt="" src="banner_right.gif" border=0></TD> </TR> <TR> <TD width=616> <TABLE cellSpacing=0 cellPadding=0 width=616 align=left border=0> <TBODY> <TR> <TD width=48><IMG height=37 alt="" src="menu_left_middle.gif" width=48 border=0></TD> </TR> </TABLE> </TD> </TR> </TBODY> </TABLE> ----------------------------------------------------------------------- bottom_screen.tmpl (present in ROOT/software/html/) ----------------------------------------------------------------------- <TABLE cellSpacing=0 cellPadding=0 width=800 border=0> <TBODY> <TR> <TD colSpan=4><BR><IMG height=49 src="footer.gif" width=800 useMap=#footer border=0></TD></TR> </TBODY> </TABLE> <!-- <MAP name=footer><AREA shape=RECT alt=Search coords=34,8,95,39><AREA shape=RECT alt="Site map" coords=108,8,188,39> <AREA shape=RECT alt="Contact us" coords=202,8,293,39 href="http://www.ucit.uc.edu/contactus.asp"> <AREA shape=RECT alt="UCit home" coords=305,8,402,39 href="http://www.ucit.uc.edu/"> </MAP>--> </BODY> </HTML> ----------------------------------------------------------------------- Though the 3 .tmpl files are getting displayed in one page, none of the '.gif' or '.css' files in top_screen.tmpl and bottom_screen.tmpl get displayed. Their actual location is ROOT/software/images/ but I put them in the same directory as the .tmpl files hoping they would work but they don't. Any idea why this might be happening? Thanks, Sharad __________________________________ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users |