I am using a plain old html template to build a website. I am using ssi includes for things like the menu and ads. These work fine for most things but when I return an output for a cgi script the ssi doesn't work. The templates for the cgi output have been wrapped in my own templates with the ssi includes. When I go to the input screen of the scripts the menu shows up but when the script returns it's output it is gone.
How can I get my cgi scripts to parse the ssi in it's template? I have tried fooling with the .htaccess file but can't seem to figure it out. Any help would be appreciated.
Marty
[search.cpan.org...]
For static HTML of course you do this:
<!--#include virtual="/path/to/script.cgi?p=value1:value2" -->
Something to note which will become apparent in a minute: the format with which I query a script from a static include is an ordinary query string, but it only has one key/value. The value is colon separated. This is to make it compatibile with @ARGV, perl's default argument vector.
To include the SSI script's output in a script within a template, I do an equivalent except as an argument vector. An ARG isn't key/value, it's a list. This is where the colon above comes in, it takes the split values as an argument vector:
$arg = "value1 value2";
$include = `perl script.cgi $arg`;
For your template, use a "marker" and substitute it instead of an include line:
(read in the template)
if ($line =~ /\<COLUMN1\>/) { $line =~ s/\<COLUMN1\>/$include/; }
You have to modify script.cgi a little bit so it can read/parse as well as accept vectors, like so. @ARGV is the default perl argument vector variable:
if (@ARGV) { ($value1,$value2)=@ARGV; }
elsif ($ENV{'QUERY_STRING'}) { %qs = &your_read_parse; ($value1,$value2)=split(/:/,$qs{'p'}); }
else { &error("No type specified"); }
The last part of the equation - you need to print a content-type for a normal SSI. If you do that for a script include, the program calling it will error or exit (hmm can't remember which it does. :-) )
if (($ENV{'QUERY_STRING'}) && ($qs{'p'})) {
print "content-type: text/html\n\n";
print "$out";
}
else { print "$out"; }
I hope this is close to what you're asking. :-)