Lori713 has asked for the wisdom of the Perl Monks concerning the following question:
I have a "header section" in rpt1 that contains a bunch of info about the report. This header section is a separate H::T file that has been populated using various TMPL_VARs and CGI params. I'd like to snag that entire header section and have it repeat on the subsequent rpt 2 and rpt3 pages. I also need the various items in this header section to help determine what parameters to use in subsequent database calls for rpt2 and rpt3.
Now, I know I can put at the beginning of rpt2.pl the following type of statements for every variable I think I'll need in the subsequent pages, but this seems to be the "hard" way to do it (I'm thinking there should be an easier "get it all at once" way):
I've tried the following at various times trying to figure this out. I think I've managed to completely confuse myself. (Note: I didn't try these all at once; I tried them separately).my $rpt_name = $CGI->param('rpt_name'); my $rpt_descr = $CGI->param('rpt_descr'); #etc., etc.
I can print out my variables like this, but I'm not sure how to then import them into the next script:
I tried to use CGI.pm's import_names in rpt2.pl, but nothing populates in the header template section as I would have expected (well, at least the CGI params, not necessarily the TMPL_VAR params):foreach my $name ( $CGI->param() ) { my $value = $CGI->param($name); print "The value of $name is $value<br>"; }
I've also tried this in rpt2.pl (that was launched from rpt1) but nothing prints out:$CGI->import_names('R'); #other stuff my $tmpl_main2 = HTML::Template->new( filename => "rpt2.tmpl", associate => $CGI, global_vars => 1, ); #other stuff print $tmpl_main2->output();
And, from the CGI.pm docs, I've tried this in rpt1.pl, hoping that the "associate=>$CGI" in rpt2.pl would pull them in:#!/usr/bin/perl use CGI ':standard'; print header(); print param('key');
I also (in desperation) tried passing the @names to the template like this but (as expected) I then get a complaint about 'passCGI' is not in my template. Even putting 'passCGI' in my template only led to further complaints about it should be a TMPL_LOOP, etc.@names = $CGI->param;
$tmpl_main1->param(passCGI => \@names);
I have searched quite a bit out in Google-land, and it seems like a lot of suggestions point to using the GET method, reading the ENV{QUERY_STRING}, parsing the stuff out, etc. However, my forms are using the POST method (but I'm not particular emotionally attached to that method... I just thought it was safer). Also, I wasn't thrilled about using hidden fields since that'll let someone view my source and see exactly what fields I'm passing around. And lastly, not all my variables are in forms.
So, since I know TIMTOWTDI, I thought I'd ask those folks who play with HTML::Template, CGI and Perl for ideas. Also, please feel free to dumb it down for me as I'm still learning this stuff. Thanks!
Lori
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML::Template, CGI, pass template params to next script
by borisz (Canon) on Feb 02, 2004 at 16:20 UTC | |
by Lori713 (Pilgrim) on Feb 02, 2004 at 17:16 UTC | |
|
Re: HTML::Template, CGI, pass template params to next script
by jdtoronto (Prior) on Feb 02, 2004 at 19:33 UTC | |
by Lori713 (Pilgrim) on Feb 02, 2004 at 20:24 UTC | |
by jdtoronto (Prior) on Feb 02, 2004 at 21:55 UTC | |
by jdtoronto (Prior) on Feb 03, 2004 at 00:44 UTC |