I got it to work!
The text file source code was not formatted correctly before -- it was all on one line. The HTML output (page.cgi) was ok, but that didn't help the random picker...
I made a few changes, most significantly being turning off "compress white space" in Links.pm. I think that was the key aspect. Is there any way to turn it off for select routines, or is it an all or nothing proposition?
The other thing I changed was wrapping each link in <p> </p> tags instead of <BR><BR> at the end. This seemed to solve the problem, but after changing a few things, I think it might have been a browser cache thing (I thought I refreshed, but maybe not) while testing the compress white space around the same time...
I also added in a few things to the subroutine in nph-build.cgi to output build results like the other subs. Here's the output text file:
http://run-down.com/featured_test.txt
Just a couple hundred more links to set isFeatured to Yes... Here's the page it will be pulled into when it is finished:
http://run-down.com/featured.shtml
And lastly, here's the full subroutine in nph-build.cgi (for anyone following along that wants to do a similar thing):
# --------------------------------------------------------
# Creates a featured sites page.
#
my ($s, $f, $e, $file, $total, $link, $sth, $featured_r, $id, $title, $url, $description);
$file = 'featured_test.txt';
$USE_HTML ?
print "Building <a href='$LINKS{build_root_url}/$file' target='_blank'>Featured</a> ... \n" :
print "Building Featured Page ... \n";
$s = time();
$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
ORDER BY $LINKS{build_sort_order_cool}
!);
$sth->execute();
# Create the HTML for the individual links.
$total = 0;
$featured_r = '';
while ($link = $sth->fetchrow_hashref) {
$total++;
$id = $link->{'ID'};
$title = $link->{'Title'};
$url = $link->{'URL'};
$description = $link->{'Description'};
$featured_r .= qq~<p><a target="_blank" href="$LINKS{db_cgi_url}/jump.cgi?ID=${$link}{'ID'}">${$link}{'Title'}</a> ${$link}{'Description'}</p>\n~;
}
open (FEATURED, ">$LINKS{build_root_path}/$file") or die ("unable to open featured page: $LINKS{build_root_path}/$file . Reason: $!");
print "\tFeatured Links: $total\n";
print FEATURED &site_featured_template ( { featured_r => $featured_r } );
close(FEATURED);
# All done.
$f = time();
$e = $f - $s;
print "Done ($e s)\n\n";
}Thanks again for all the help getting this to work! It took a while, and I still have a lot of links to change, but long-term it will be a HUGE time saver.
Dan
[This message has been edited by Dan Kaplan (edited March 17, 2000).]
The text file source code was not formatted correctly before -- it was all on one line. The HTML output (page.cgi) was ok, but that didn't help the random picker...
I made a few changes, most significantly being turning off "compress white space" in Links.pm. I think that was the key aspect. Is there any way to turn it off for select routines, or is it an all or nothing proposition?
The other thing I changed was wrapping each link in <p> </p> tags instead of <BR><BR> at the end. This seemed to solve the problem, but after changing a few things, I think it might have been a browser cache thing (I thought I refreshed, but maybe not) while testing the compress white space around the same time...
I also added in a few things to the subroutine in nph-build.cgi to output build results like the other subs. Here's the output text file:
http://run-down.com/featured_test.txt
Just a couple hundred more links to set isFeatured to Yes... Here's the page it will be pulled into when it is finished:
http://run-down.com/featured.shtml
And lastly, here's the full subroutine in nph-build.cgi (for anyone following along that wants to do a similar thing):
Code:
sub is_featured { # --------------------------------------------------------
# Creates a featured sites page.
#
my ($s, $f, $e, $file, $total, $link, $sth, $featured_r, $id, $title, $url, $description);
$file = 'featured_test.txt';
$USE_HTML ?
print "Building <a href='$LINKS{build_root_url}/$file' target='_blank'>Featured</a> ... \n" :
print "Building Featured Page ... \n";
$s = time();
$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
ORDER BY $LINKS{build_sort_order_cool}
!);
$sth->execute();
# Create the HTML for the individual links.
$total = 0;
$featured_r = '';
while ($link = $sth->fetchrow_hashref) {
$total++;
$id = $link->{'ID'};
$title = $link->{'Title'};
$url = $link->{'URL'};
$description = $link->{'Description'};
$featured_r .= qq~<p><a target="_blank" href="$LINKS{db_cgi_url}/jump.cgi?ID=${$link}{'ID'}">${$link}{'Title'}</a> ${$link}{'Description'}</p>\n~;
}
open (FEATURED, ">$LINKS{build_root_path}/$file") or die ("unable to open featured page: $LINKS{build_root_path}/$file . Reason: $!");
print "\tFeatured Links: $total\n";
print FEATURED &site_featured_template ( { featured_r => $featured_r } );
close(FEATURED);
# All done.
$f = time();
$e = $f - $s;
print "Done ($e s)\n\n";
}
Dan
[This message has been edited by Dan Kaplan (edited March 17, 2000).]