The reason I created a whole file for the short/long display was that I couldn't figure out how to tell people to change from one to the other. But I'll give it a shot.
This is how to change the regular html.pl to a short display.
sub html_record_form stays the same
rename sub html_record to
sub html_record_long In sub html_record_long (the one you just renamed) add the following just after
my (%rec) = @_;
Code:
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;
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>
|;
}
Create a new subroutine -- sub html_record
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?$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 -- >
print qq|
<a href="$long_url">$rec{'Title'}</a>
|;
# <-- End of short display formatting -- >
print "</TD>"; # do not remove this! It is necessary to make the records display properly
}
In sub html_view_success, replace
Code:
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}
# Go through each hit and convert the array to hash and send to
# html_record for printing.
for (0 .. $numhits - 1) {
print "<P>";
&html_record (&array_to_hash($_, @hits));
}
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}
with
Code:
if (($db_total_hits == 1) or ($maxhits == 1)) {
&html_record_long(&array_to_hash(0, @hits));
}
else {
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 ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>";}
}
In sub html_delete_form, change
Code:
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}
if ($status ne "ok") { # There was an error searching!
print qq|<P><FONT COLOR="RED" SIZE=4>Error: $status</FONT></P>|;
}
else {
print "<P>";
for (0 .. $numhits - 1) {
%tmp = &array_to_hash($_, @hits);
print qq|<TABLE BORDER=0><TR><TD><INPUT TYPE=CHECKBOX NAME="$tmp{$db_key}" VALUE="delete"></TD><TD>|;
&html_record (%tmp);
print qq|</TD></TR></TABLE>\n|;
}
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}
}
to
Code:
if ($status ne "ok") { # There was an error searching!
print qq|<P><FONT COLOR="RED" SIZE=4>Error: $status</FONT></P>|;
}
else {
if (($db_total_hits == 1) or ($maxhits == 1)) {
print qq|
<p><$font>
If you would like to delete this record, check the box and then press "Delete Records":</font>|;
%tmp = &array_to_hash(0, @hits);
print qq|<table><tr><td valign=top><INPUT TYPE=CHECKBOX NAME="$tmp{$db_key}" VALUE="delete"></td><td>|;
&html_record_long(&array_to_hash(0, @hits));
print qq|</td></tr></table>
|;
}
else {
print qq|
<p><$font>
Check which records you wish to delete and then press "Delete Records":<br>
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) {
%tmp = &array_to_hash($_, @hits);
print qq|<TR><TD valign=top><INPUT TYPE=CHECKBOX NAME="$tmp{$db_key}" VALUE="delete"></TD>|;
&html_record (%tmp);
print "</tr>";
++$i;
}
print "</table>";
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>"; }
}
}
In sub html_modify_form, change
Code:
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}
# Go through each hit and convert the array to hash and send to
# html_record for printing. Also add a radio button with name=modify
# and value=key.
if ($status ne "ok") { # Error searching database!
print qq|<P><FONT COLOR="RED" SIZE=4>Error: $status</FONT>|;
}
else {
print "<P>";
for (0 .. $numhits - 1) {
%tmp = &array_to_hash($_, @hits);
print qq|<TABLE BORDER=0><TR><TD><INPUT TYPE=RADIO NAME="modify" VALUE="$tmp{$db_key}"></TD><TD>|;
&html_record (%tmp);
print qq|</TD></TR></TABLE>\n|;
}
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}
}
to
Code:
if ($status ne "ok") { # Error searching database!
print qq|<P><$font_error>Error: $status</FONT>|;
}
else {
if (($db_total_hits == 1) | | ($maxhits == 1)) {
print qq|
<p><$font>
If you would like to modify this record, select the button and then press "Modify Record":</font>
|;
%tmp = &array_to_hash(0, @hits);
print qq|<INPUT TYPE=RADIO NAME="modify" VALUE="$tmp{$db_key}">|;
&html_record_long(&array_to_hash(0, @hits));
}
else {
print qq|
<p><$font>
Check which record you wish to modify and then press "Modify Records":<br>
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) {
%tmp = &array_to_hash($_, @hits);
print qq|<TR><TD valign=top><INPUT TYPE=RADIO NAME="modify" VALUE="$tmp{$db_key}"></TD>|;
&html_record (%tmp);
print "</tr>";
++$i;
}
print "</table>";
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>"; }
}
}
------------------
JPD