CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Template Toolkit not finding templates

 



yogaboy
Novice

Jun 8, 2009, 2:28 PM

Post #1 of 9 (922 views)
Template Toolkit not finding templates Can't Post

Hi,

I try running the following (snippet of) code within a CGI page, and it produces the error beneath. What I don't understand is, it all works if I put the templates in the same dir as the cgi, or if I use ttree. The docs aren't clear on where the INCLUDE_PATH begins (server root, webserver root, current dir...?) but I've tried absolute paths, relative, tild... every way I can think of. I don't know how get any more information to help debug, I got the stack trace using use CGI::HTMLError trace => 1;

Any help is much appreciated.


Code
my $form = CGI::FormBuilder->new( 
name => 'books'
,fields => \@fields
,validate => {
title => 'VALUE'
,author => '/\w+\s+\w+.*/'
,pages => 'INT'
,owners => 'INT'
}
,method => 'post'
,template => {
type => 'TT2'
,template => 'BookInsert.tt'
,variable => 'form'
,INCLUDE_PATH => [
#main.config filr in ttreerc dir
'~/Sites/templates/ttreerc/'
#BooksInsert.tt in src dir
,'~/Sites/local.main.local/templates/src'
#headers and footers in lib dir
,'~/Sites/local.main.local/templates/lib'
,'~/Sites/local.main.local/templates/dest'
],
# pre-process lib/config to define any extra values
,PRE_PROCESS => 'main.config'
}
);




Code
[FormBuilder] Fatal: file error - BookInsert.tt: not found at /usr/local/lib/perl5/site_perl/5.8.8/CGI/FormBuilder.pm line 1530



KevinR
Veteran


Jun 8, 2009, 2:42 PM

Post #2 of 9 (921 views)
Re: [yogaboy] Template Toolkit not finding templates [In reply to] Can't Post

Run this:


Code
#!/usr/bin/perl  
print "Content-type: text/html\n\n";
foreach $key (sort keys(%ENV)) {
printf("<font color=crimson face=verdana size=2>%-10.20s:</font>
<font color=blue size=2 face=verdana><b>$ENV{$key}</b></font><br>", $key);
}
exit;

DOCUMENT_ROOT is almost always the root path to use on a webserver. So if you have a folder in the webroot named 'files' your path to it might be something like:

home/user/uniqueid/public_html/files

Just run the above code and you will see what the root is for your server.
-------------------------------------------------


(This post was edited by KevinR on Jun 8, 2009, 2:45 PM)


yogaboy
Novice

Jun 10, 2009, 6:47 AM

Post #3 of 9 (902 views)
Re: [KevinR] Template Toolkit not finding templates [In reply to] Can't Post

Thanks.

document root is /Users/yb/Sites/local.main.local/http/

do you have any idea how I can check what TT is looking in? - some sort or eval or DEBUG statement, to catch the values in the hash, perhaps. I've read all the docs for TT and Formbuilder, but no mention of this.


KevinR
Veteran


Jun 10, 2009, 11:42 AM

Post #4 of 9 (899 views)
Re: [yogaboy] Template Toolkit not finding templates [In reply to] Can't Post

replace your user defined paths, for example:

'~/Sites/templates/ttreerc/'

with:

'/Users/yb/Sites/templates/ttreerc/'

See if that works. If not try this:

/Users/yb/Sites/local.main.local/http/templates/ttreerc/'

or some variation of the same
-------------------------------------------------


yogaboy
Novice

Jun 11, 2009, 7:59 AM

Post #5 of 9 (887 views)
Re: [KevinR] Template Toolkit not finding templates [In reply to] Can't Post

I've tried absolute, relative, and unexpanded paths with the tild, and I've added the ABSOLUTE => 1 property, and the RELATIVE => 1 property. Nothing has worked.

I'm completely stumped, which is why I'd really like a way to get the full stack trace, but I've no idea how?


KevinR
Veteran


Jun 11, 2009, 10:02 AM

Post #6 of 9 (885 views)
Re: [yogaboy] Template Toolkit not finding templates [In reply to] Can't Post

Have you tried using .. instead ~ ?

../path/to/files
-------------------------------------------------


yogaboy
Novice

Jun 11, 2009, 2:04 PM

Post #7 of 9 (882 views)
Re: [KevinR] Template Toolkit not finding templates [In reply to] Can't Post

yes, and I've moved the folders into the root dir, which doesn't work either. Basically, it only works when the files are in the same dir as the calling cgi script.


KevinR
Veteran


Jun 11, 2009, 2:52 PM

Post #8 of 9 (881 views)
Re: [yogaboy] Template Toolkit not finding templates [In reply to] Can't Post

Sorry, I don't know what else to suggest. Try http://www.perlmonks.com and hopefully someone there can offer a suggestion
-------------------------------------------------


yogaboy
Novice

Jun 12, 2009, 2:58 AM

Post #9 of 9 (870 views)
Re: [KevinR] Template Toolkit not finding templates [In reply to] Can't Post

Thanks for taking the time on this anyway. Much appreciated.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives