Gossamer Forum
Home : Products : DBMan : Customization :

More SSI/Javascript Headaches.

Quote Reply
More SSI/Javascript Headaches.
Hi guys,
Getting a major headache here. I've been 2 days at this to no avail. I'm using DB man and I'm trying to do something very simple, put DBMan's output in the middle of an .SHTML file... everything I've tried either doesn't work or doesn't work fully. Here's the problem. I have both javascript for the image rollovers and <--!include virtual's--> for the banner rotator in the HTML.

I've tried
1. Splitting the file in two and using DB Man to load and print a header and footer with the thot of inserting the database output in the middle. Problem: the SSI's and Javascripts don't work. I've tried several versions of some include subs I've found in the forums and FAQ to no avail.
2. Throwing all the HTML code into DB Man and using the $insertadvert from the faq. Problem, Javasripts still don't work and I can't get the $insertadvert to work either (Yep, I checked and used the correct symbol and tried print $insertadvert... did nothing);
3. Was suggested that I try to use CGI::SSI... no luck. it's a commercial server and not installed and no telnet to install it.

To give you an idea of what I'm trying to accomplish: I have the photo upload mod installed and I'm trying to search the database on one field. If that field matches, it displays one photo per match. If a user clicks on the photo, DB Man does a search based on the ID and shows all the photos. So far that all works, I just need to insert the final results in an HTML that looks like the rest of the site.

Here's the banner rotator I'm trying to call : /cgi-bin/WWWAdverts/WWWAdvertsSSI.cgi?lg=All&kw=Sponsor

Thanks in advance for the help.
Famous Last words:
"Dragon? What dragon?"
Quote Reply
Re: [dunsel] More SSI/Javascript Headaches. In reply to
Can you get ssi to work at all?

I've used this include before on websites with dbman and it has worked... example:

<!--#include virtual="/cgi-bin/rates/db.cgi?db=default&uid=default&view_records=1&ID=*" -->

Pay close attention to the spaces (or lack thereof) - no space at the front of the comment tag, and one space before the end of the comment tag.


PS: if you want the JavaScript to work within DBMan you'll need to "pull" them in from a js file.

Example <SCRIPT LANGUAGE="JavaScript" SRC="http://www.yourdomain.com/bob.js"></SCRIPT>

Then create a file called bob.js and type in your javascript there.

The reason for this is that the brackets { } and other goodies that make javascript run also freak out Perl. Perl won't "see" the JavaScript or even know it is there if you use the "external" method.

Last edited by:

Watts: Oct 25, 2004, 3:43 PM
Quote Reply
Re: [Watts] More SSI/Javascript Headaches. In reply to
Hi, thanks for the reply but I think you misunderstood. SSI works fine. It's when I try to display a web page with includes and put DB Man results in it. Lemme explain a lil better.

I have page A. Page A goes through the database and displays one photo for each record that matches the search. The link on the photo it displays is to another page (page B) that displays all of the photos for that record. Page A has includes and is called from the index so it displays the includes properly. Page B has includes and will be generated from a header and footer. It has includes. Perl doesn't do includes or java script so page B doesn't display properly.
I've searched the forums and the FAQ and so far, the only solution I have is one I've hobbled together and it's a very inelegant one:
When a browser displays page A and a record matches, I have DB man load the header for page B, create the database results for page B, then load a footer and save it as $rec('ID').shtml:

My code:

Here's where page A loads a photo from the database and gives it a <a href>

print qq|
<a href="http://www.mysite.com/$rec{'ID'}.shtml" target="_self">
<img src= "$SAVE_DIRECTORY_URL/$rec{$db_key}/$file" border="0">
</a>
|;

Immediately after displaying this photo I have DB man generate the page for it:

##################################################
# create the output and stuff the header into it

$output="> /usr/local/plesk/apache/vhosts/mysite.com/httpdocs/$rec{'ID'}.shtml";
open(NEW, $output);
open(FD, "< header.tpl");
@file_data = <FD>;
foreach $line (@file_data)
{
print NEW $line;
}
close FD;

#Load all the photos for this record and print them into NEW

opendir (GRAPHIC, "$SAVE_DIRECTORY/$rec{$db_key}") or &cgierr("unable to open directory: $SAVE_DIRECTORY/$rec{$db_key}. Reason: $!");
@files = readdir(GRAPHIC);
(GRAPHIC);
foreach $file (@files)
{
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
print NEW qq|<img src= "$SAVE_DIRECTORY_URL/$rec{$db_key}/$file" border="0"></p><p>|;
}

#Now add in the footer

open(FD, "< foot.tpl");
@file_data = <FD>;
foreach $line (@file_data)
{
print NEW $line;
}
close FD;
close NEW;

As I said, it's not pretty, it leaves .shtml files scattered in the root and doesn't remove them wasting space, if a record gets deleted the corresponding .shtml doesn't, etc.

It works tho (Programmers axiom, when the only tool you have is a hammer, everything begins to look like a nail). It just seems to me there's got to be a better way of doing this.
Famous Last words:
"Dragon? What dragon?"