Small problem.. In the short display, this code works fine. If ssi=1 is detected, no headers. If not, they are displayed.
However, When I go to the long display, no headers are displayed either. I bet its the way the short/long builds the $long url.. but I can't seem to pin point the problem.
Here is my Code for the Short Record Display.
Code:
sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.
# This is the "short display" -- the list of records that are returned
# from a search.
my (%rec) = @_;
# create link to full display
$record_number = ((($nh - 1) * $db_max_hits) + $i);
$long_url = $ENV{'QUERY_STRING'};
$long_url =~ s/\&nh=\d+//;
$long_url =~ s/\&mh=\d+//;
# $long_url = "$db_script_url?$db_key=$rec{$db_key}&nh=$record_number&mh=1";
$long_url = "$db_script_url?$long_url&nh=$record_number&mh=1";
# print "<TD>"; # do not remove this! It is necessary to make the records display properly
# Below is where you define what you want to appear for each record in the "short" display.
# You can make this whatever you want, and display as many fields as you would like.
# Choose which of the fields you would like for users to click on to reach the full display
# of records and use that field name in place of "Title" below.
#
# Be sure that you use <a href="$long_url"> for the link to your full record display.
# <-- Start of short display formatting -- >
($db_auto_generate and print &build_html_record(%rec) and return);
my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';
$url{'e-mail'} = $rec{'e-mail'};
$url{'e-mail'} =~ s/<\/?B>//g;
$rec{'short_desc'} =~ s/\n/<BR>/g;
$rec{'long_desc'} =~ s/\n/<BR>/g;
$url{'url'} = $rec{'url'};
$url{'url'} =~ s/<\/?B>//g;
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=0>|;
print qq|
<TR><TD ALIGN="left" VALIGN="TOP" WIDTH="90%"><$font>
<b><font color=364276>$rec{'title'}</b></font><br>
<b>Rating:</b> <img align="center" src="http://www.fragdot.com/staff/stars/$rec{'rating'}.gif"><br>
<b>$rec{'category'} by: <a href="mailto:$url{'e-mail'}">$rec{'userid'}</a></b> <small>( $rec{'date'} )</small><br>
|;
if ($rec{'url'}) {
print qq|
<b>Related Link:<a href="$url{'url'}">$rec{'url'}</a></b><br><br>
|;
}
print qq|
$rec{'short_desc'}
|;
print qq|
[ <a href="$long_url">Read the Review</a> ]<br><br></font>
|;
sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.
# This is the "short display" -- the list of records that are returned
# from a search.
my (%rec) = @_;
# create link to full display
$record_number = ((($nh - 1) * $db_max_hits) + $i);
$long_url = $ENV{'QUERY_STRING'};
$long_url =~ s/\&nh=\d+//;
$long_url =~ s/\&mh=\d+//;
# $long_url = "$db_script_url?$db_key=$rec{$db_key}&nh=$record_number&mh=1";
$long_url = "$db_script_url?$long_url&nh=$record_number&mh=1";
# print "<TD>"; # do not remove this! It is necessary to make the records display properly
# Below is where you define what you want to appear for each record in the "short" display.
# You can make this whatever you want, and display as many fields as you would like.
# Choose which of the fields you would like for users to click on to reach the full display
# of records and use that field name in place of "Title" below.
#
# Be sure that you use <a href="$long_url"> for the link to your full record display.
# <-- Start of short display formatting -- >
($db_auto_generate and print &build_html_record(%rec) and return);
my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';
$url{'e-mail'} = $rec{'e-mail'};
$url{'e-mail'} =~ s/<\/?B>//g;
$rec{'short_desc'} =~ s/\n/<BR>/g;
$rec{'long_desc'} =~ s/\n/<BR>/g;
$url{'url'} = $rec{'url'};
$url{'url'} =~ s/<\/?B>//g;
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=0>|;
print qq|
<TR><TD ALIGN="left" VALIGN="TOP" WIDTH="90%"><$font>
<b><font color=364276>$rec{'title'}</b></font><br>
<b>Rating:</b> <img align="center" src="http://www.fragdot.com/staff/stars/$rec{'rating'}.gif"><br>
<b>$rec{'category'} by: <a href="mailto:$url{'e-mail'}">$rec{'userid'}</a></b> <small>( $rec{'date'} )</small><br>
|;
if ($rec{'url'}) {
print qq|
<b>Related Link:<a href="$url{'url'}">$rec{'url'}</a></b><br><br>
|;
}
print qq|
$rec{'short_desc'}
|;
print qq|
[ <a href="$long_url">Read the Review</a> ]<br><br></font>
|;
}
Here is the Long Display Code
Code:
sub html_record_long {
#----------------------------------------------------------------
my (%rec) = @_;
if ($db_total_hits > 1) {
# create links to previous and next records
$next_url = $ENV{'QUERY_STRING'};
$next_url =~ s/\&nh=\d+//;
$next_hit = $nh + 1;
$prev_hit = $nh - 1;
# Below is where you define your form.
# <-- Start of record display -->
($db_auto_generate and print &build_html_record(%rec) and return);
my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';
$url{'e-mail'} = $rec{'e-mail'};
$url{'e-mail'} =~ s/<\/?B>//g;
$rec{'short_desc'} =~ s/\n/<BR>/g;
$rec{'long_desc'} =~ s/\n/<BR>/g;
$url{'url'} = $rec{'url'};
$url{'url'} =~ s/<\/?B>//g;
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=0>|;
print qq|
<TR><TD ALIGN="left" VALIGN="TOP" WIDTH="90%"><$font>
<b><font color=364276>$rec{'title'}</b><br></font>
<b>Rating:</b> <img align="center" src="http://www.fragdot.com/staff/stars/$rec{'rating'}.gif"><br>
<b>$rec{'category'} by: <a href="mailto:$url{'e-mail'}">$rec{'userid'}</a></b> <small><$font>( $rec{'date'} )</small><br>
|;
if ($rec{'url'}) {
print qq|
<b>Related Link: <a href="$url{'url'}">$rec{'url'}</a></b><br><br>
|;
}
print qq|
$rec{'long_desc'}<br><br>
|;
print qq|
<center>
|;
if ($prev_hit) {
$previous = qq~<a href="$db_script_url?$next_url&nh=$prev_hit"><$font>Previous</font></a>~;
}
else { $previous = " "; }
if ($next_hit <= $db_total_hits) {
$next = qq~<a href="$db_script_url?$next_url&nh=$next_hit"><$font>Next</font></a>~;
}
else { $next = " "; }
# create link back to short display
$list_url = $next_url;
$list_url =~ s/\&mh=\d+//;
$mh = $db_max_hits;
$lh = int(($nh-1)/$mh) + 1;
$list = qq~<a href="$db_script_url?$list_url&nh=$lh"><$font>Back to record list</font></a>~;
# print out the links
print qq|
<table width=100%>
<tr><td width=50%>$previous</td>
<td width=50% align=right>$next</td></tr>
<tr><td colspan=2 align=center>$list</td></tr>
<tr><td colspan=2 align=center><$font>Record $nh of $db_total_hits</font></table>
|;
}
# <-- End of record display -->
}
And here is the View Success
Code:
sub html_view_success {
# --------------------------------------------------------
# This page displays the results of a successful search.
# You can use the following variables when displaying your
# results:
#
# $numhits - the number of hits in this batch of results.
# $maxhits - the max number of hits displayed.
# $db_total_hits - the total number of hits.
# $db_next_hits - html for displaying the next set of results.
#
my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);
$in{'nh'} ? ($nh = $in{'nh'}) : ($nh = 1);
$page_title = "Search Results";
# detect if ssi=1, and if so don't print the top of the page
if (! $in{'ssi'}) { &html_page_top; }
&html_print_headers;
# Go through each hit and convert the array to hash and send to
# html_record for printing.
if (($db_total_hits == 1) | | ($maxhits == 1)) {
&html_record_long(&array_to_hash(0, @hits));
}
else {
if (! $in{'ssi'}) {
print qq|<p><$font>Your search returned <b>$db_total_hits</b> matches.</font>|;
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>"; }
}
$i = 1;
print "<table>";
for (0 .. $numhits - 1) {
print "<tr>";
&html_record (&array_to_hash($_, @hits));
print "</tr>";
++$i;
}
print "</table>";
if (! $in{'ssi'}) {
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>";}
}
}
if (! $in{'ssi'}) {
&html_footer;
&html_page_bottom;
}
}
------------------
The Crowe
crowe@charter.net www.lit.org Links Engine for Writing on the net!