in reply to HTML::Template Help
#!/usr/bin/perl -w use CGI qw(:standard); use HTML::Template; use strict; my $output = new CGI; my $baseDir = "/home/projects/scripts/devsimp"; my @names = $output->param; @INC = ('../cgi-lib', '/usr/lib/perl5/site_perl', '/usr/lib/perl5/5.00503'); require 'cgi-lib.pl'; ### $inputlist Gets all the stuff from the form. my $inputlist = &get_form_input(); &show_browser_output(); exit 0; sub show_browser_output { ### Based on, basically which section and what page number, ### $templatename gets the appropriate template to use for output my $templatename = &get_template(); my $a = ""; my $b = ""; ### %params gets the parts to fill in the blanks in the template ### my %params = &get_params(); my $template = HTML::Template->new(filename => "$baseDir/templates/$ +templatename"); print "Content-type: text/html\n\n"; while (($a, $b) = each(%params)) { $template->param( $a => $b ); } print $template->output; } ### Determines template to use based on subset of the form values' nam +es. ### sub get_template { ###Code to determine which template to use ### return $template; } ### Get the parts to fill in the blanks in the template ### sub get_params { my %param = (); my $page_header = ""; my $page_paragraph = ""; my $page_questions = ""; my $curr_page = $page_num; my $new_page_num = ""; ####Code to fill up the parameters that are going to be displayed ### %param = ( CAT => "$shorthand{$startingcat}", HEADER => "$page_header", PARAGRAPH => "$page_paragraph", PAGE => $new_page_num, QUESTIONS => "$page_questions", TEST_TEXT => $names[0], TEST_TEXT1 => $names[1], TEST_TEXT2 => $names[2] ); return %param; } ### Gets names of every form field submitted. ### sub get_form_input { my $listofparams = ""; my $c = ""; my @input = ""; foreach $c (@names) { $listofparams .= "$c, "; } return $listofparams; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) 2Re: HTML::Template Help
by jeffa (Bishop) on Aug 09, 2001 at 19:45 UTC | |
|
Re2: HTML::Template Help
by pmas (Hermit) on Aug 13, 2001 at 19:50 UTC |