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

check my logic, please (useful if it works)

Quote Reply
check my logic, please (useful if it works)
Hello everyone,

I'm creating a script called header.cgi that will call header.txt from the templates directory, require Links.pm and replace any <%variable%> with the appropiate $LINK{'variable'}, and place it on whatever webpage calls it with <!--#exec cgi="/admin/header.cgi"--. With this, I can have the same header.txt and footer.txt on the entire site with the same variables but not have to go and make a template and a subroutine in nph-build.cgi, etc.

Here is what I've done so far:

#!/usr/bin/perl
#
# Dan's Header Script That Works With Links SQL
# Created for CSNhome.com
#

require "Links.pm";

open(HEADER,"templates/header.txt");
@header = <HEADER>;
close(HEADER);
$tags = join("",@header);

$tags =~ s/~\<\%site_title\%>\}~/$LINKS{'build_site_title'}/g;
$tags =~ s/~\<\%images\%>\}~/$LINKS{'images_directory'}/g;
$tags =~ s/~\<\%font\%>\}~/$LINKS{'normal_font'}/g;

print "$tags";


then I just call that from any .shtml page with <!--#exec cgi="/admin/header.cgi"--, shoudn't that work? Here is what the error log gave me:

httpd: [Mon Nov 27 21:12:36 2000] [error] [client 172.160.206.102] invalid CGI ref "/admin/header.cgi" in /www/csnhome/test.shtml
httpd: [Mon Nov 27 21:13:23 2000] [error] [client 172.160.206.102] invalid CGI ref "admin/header.cgi" in /www/csnhome/test.shtml


Thanks for any input! God bless!

<><------------><>
Daniel
http://www.christian-search.net
<><------------><>
Quote Reply
Re: check my logic, please (useful if it works) In reply to
The problem is that you won't have access to the %GLOBALS variables, and you are doing a lot of work for little benefit.

Why not just have the nph-build routine print out a header.inc file every time it's run. That has the current updated header in it, and you just include that file in an SSI call. Why waste the time to parse it??

To do a proper parsing you'd still need to load Template.pm and send the data to it via an &load_template call.

Writing out the header file (like I do with the sidebar file) is a good way to keep the site up to date.



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