Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Building a New Template

Quote Reply
Building a New Template
Hello everyone!

I wanted to add a Terms and Agreements page that everyone agrees to when then submit a link to my search engine. I created the template (terms.html), added the subroutine in HTML_Template.pm (and to @EXPORTS):

Code:
sub site_html_terms_and_agreements {
# --------------------------------------------------------
# This routine will build a what's new page.
#
my ($tags, $dynamic) = @_;
my $template = defined $dynamic ? $dynamic->param('t') : undef;
(ref $tags eq 'HASH') or croak "HTML_TEMPLATES: Argument '$tags' must be hash reference";

defined $dynamic and &load_user ($dynamic, $tags);
my $output = &load_template ('terms.html', {
%$tags,
%GLOBALS
}, undef, $template );
defined $dynamic and &clean_output($dynamic, \$output);
return $output;
}
add a variable for it in Links.pm:

Code:
# The path and URL to the terms and agreements page
$LINKS{build_terms_and_agreements_path} = "$LINKS{build_root_path}/terms_and_agreenments$LINKS{build_extension}";
$LINKS{build_terms_and_agreements_url} = "$LINKS{build_root_url}/terms_and_agreements$LINKS{build_extension}";
and then placed this subroutine (which I created from others) in nph-build.cgi:

Code:
sub build_terms_and_agreements {
# --------------------------------------------------------
# Creates the terms and agreements page.
#
my ($s, $e, $f);

$USE_HTML ?
print "Building <a href='$LINKS{build_terms_and_agreements}' target='_blank'>Terms and Agreements Page</a> ... \n" :
print "Building Terms and Agreements Page ... \n";
$s = time();

open (TERMS, ">$LINKS{build_terms_and_agreements_path}") or die "unable to open terms and agreements page: $LINKS{build_terms_and_agreements}. Reason: $!";
print TERMS &site_html_terms_and_agreements (\%OUT);
close TERMS;
print "\tClosing page.\n";

$f = time();
$e = $f - $s;
print "Done ($e s)\n\n";
}
and I got a software error saying complication errors. I know the problem lies in the nph-build.cgi subroutine because that is the only one I'm not sure on. So can someone look it over and tell me what I'm doing wrong? Thanks and God bless!

<><------------><>
Daniel
http://www.christian-search.net
<><------------><>
Quote Reply
Re: Building a New Template In reply to
I figured out that I must remove the /%OUT in the print TERMS &site_html_terms_and_agreements (); it it started to work. But now, when I run nph-build.cgi, it gives me this software error:

HTML_TEMPLATES: Argument '' must be hash reference at nph-build.cgi line 790

becuase this line of code messed up in HTML_Templates.pm under the subroutine for terms.html:

(ref $tags eq 'HASH') or croak "HTML_TEMPLATES: Argument '$tags' must be hash reference";

so my question is, what are the $tags and how do I get them to eq HASH? Thanks and God bless!


<><------------><>
Daniel
http://www.christian-search.net
<><------------><>
Quote Reply
Re: Building a New Template In reply to
&site_html_terms_and_agreements(\%OUT) was correct, the
(\%OUT) part is what becomes %$tags in the template routines. You may need to get something placed into this hashref before your plan will work, I'm not sure.

But put that back in for now and double check this for me: I think your problem is actually because you didn't add the sub to the @EXPORT line in HTML_Templates.pm, this is one of the first parts of the file near to line 35 and it should take up close to 8 lines make sure you add &site_html_terms_and_agreements in that line somewhere and you should be allright.

Quote Reply
Re: Building a New Template In reply to
I put the /%OUT back and double check the &site_html_terms_and_agreements in EXPORTS (which I already had there) and it gave me my orginal error when I run nph-build.cgi (software error due to complication errors).

I don't know what is could be now. Thanks for your help!

<><------------><>
Daniel
http://www.christian-search.net
<><------------><>
Quote Reply
Re: Building a New Template In reply to
check your error log. Very often that is an undefined variable or a missing closing tag.

PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://postcards.com/FAQ


Quote Reply
Re: Building a New Template In reply to
ok, i got error logs installed on my domain and this is what it said when i ran nph-build.cgi:

[Sun Nov 19 16:03:39 2000] nph-build.cgi: Global symbol "OUT" requires explicit package name at nph-build.cgi line 790.
[Sun Nov 19 16:03:39 2000] nph-build.cgi: Execution of nph-build.cgi aborted due to compilation errors.


so the problem still lies in the /%OUT and the $tags stuff. Ideas? God bless!


<><------------><>
Daniel
http://www.christian-search.net
<><------------><>
Quote Reply
Re: Building a New Template In reply to
means you have to give the variable out an explicit package name...
you do this simply by using:

my %OUT; as the first ref to it

Quote Reply
Re: Building a New Template In reply to
That did it! So if you want to use this mod, just follow the directions in the first thread but add a my %OUT; in the nph-build.cgi subroutine.

Thanks to everyone's help! God bless!

<><------------><>
Daniel
http://www.christian-search.net
<><------------><>
Quote Reply
Re: Building a New Template In reply to
Hello everyone,

I want to incorporate my new template into page.cgi now. Here is what I've done so far:

add my ($terms_match) = $LINKS{build_terms_and_agreements} =~ m,^$LINKS{build_terms_and_agreements}/(.+),o; to the top of page.cgi under #Figure out what to look for.

add ($page =~ /^$terms_match/o) and do { &generate_terms_page ($in); last CASE; } to top of page.cgi under CASE: {

add sub generate_terms_page {
# --------------------------------------------------------
# This routine build a single page for every link.
#
my $in = shift;
my ($terms_match);

$page = $in->param('g');
($terms_match) = $LINKS{build_terms_and_agreements} =~ m,^$LINKS{build_terms_and_agreements}/(.+),o;
($id) = $page =~ m,$terms_match/(\d+),o;

if (!$id) {
print $in->header();
&site_html_error ( { error => "Sorry, I'm not sure what page you are asking for: '$page'" }, $in);
return;
}

$link = $LINKDB->get_record ($id, 'HASH');

if (!$link) {
print $in->header();
&site_html_error ( { error => "Sorry, we don't seem to have link '$id'" }, $in);
return;
}
$category = $CATDB->get_record ($link->{'CategoryID'}, 'HASH');
$title_linked = &build_linked_title ($category->{'Name'} . "/" . $link->{'Title'});

print $in->header();
print &site_html_terms_and_agreements ($link, { grand_total => $GRAND_TOTAL, title_linked => $title_linked }, $in);
}
into page.cgi

i just copied the subroutine for the detailed page and then tried to modify it with the variables I have. I can figure what needs to be edited but I would like to get help with this first. I also posted this in the same forum thread so that people can use this as a resource. Thanks!

<><------------><>
Daniel
http://www.christian-search.net
<><------------><>