Gossamer Forum
Home : Products : DBMan : Customization :

headlines.cgi help needed.

Quote Reply
headlines.cgi help needed.
Gang,

I just set up Headlines.cgi at a new site for the National Academy of Emergency Medical Dispatch (http://www.naemd.org). I had already created a What's New section using DBMan but wanted to add the headlines to the home page using SSI.

Here's my problems:
1. I set "my $LASTX = 2;" to 2 because it seems to want to add one more headline than I set it for. You will see on the home page that there are three headlines. How is that? Also, when it was set to 4 from the default script it listed 5 headlines. The problem was that there were only three entries in the database so it picked up the first two entries and listed them again. When I changed the number to 3 it did the same thing but only picked up one of the data entries and repeated it. How come it does that?

2. In the section of:

#### modify the path and filename of your db
$db_file_name = "/home/n/naemd/public_html/scripts/new.db";
$db_script_url = "http://www.naemd.org/scripts/db.cgi";

I had to add the second line of "$db_script_url = " in order to get the link to work correctly. I didn't see this referenced in the Forum so I don't know if this is a bug or if I had the script set up wrong. Do you know?

I don't know if this will print here in this forum correctly but here is what I have. Can anyone see any problems or make suggestions?

#!/usr/local/bin/perl
### change to match your server path
### Display latest headlines ####

#### modify the path and filename of your db
$db_file_name = "/home/n/naemd/public_html/scripts/new.db";
$db_script_url = "http://www.naemd.org/scripts/db.cgi";

open (DB, "<$db_file_name") or &cgierr("error in modify_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
my @lines = <DB>; # Slurp the database into @lines..
close DB;
my $LASTX = 2; # How many headlines do you want?
for ($i=$#lines; $i>=($#lines - $LASTX); $i--) {
chomp $lines[$i];
@data = split(/\|/,$lines[$i]);
$latest .= qq|<img src="../graphics/tri-bullet-left.gif" width="13" height="13" border="0" alt=""> <A HREF="$db_script_url?db=new&uid=default&ID=$data[0]&view_records=1">$data[2]</A><p>|;
#$data[0] is record ID, $data[2] is title in my DB
}
print $latest;

1;
####### end display latest headlines #######

On our index.shtml page I use the SSI command of:



Thanks in advance for any help or insights.

Richard

Richard Bilger
RBilger@MERGInet.com
MERGInet Medical Resources
http://www.merginet.com