##################################################################### # Short/Long Display from regular html.pl file # by JPDeni # Last Modified: 25 Jul 2000 # ###################### # # Replace the following subroutine in your html.pl file: 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) + $rec_count); $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 ""; # 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 for the link to your full record display. # <-- Start of short display formatting -- > print qq| $rec{'Name'} $rec{'Catergory'} |; # if you want to display your fields in columns, use the following format: # print qq| # $rec{'Field'} # $rec{'Field'} # $rec{'Field'} # $rec{'Field'}|; # Add or remove columns as needed. Be sure you add the $long_url link to one of your fields # <-- End of short display formatting -- > print ""; # do not remove this! It is necessary to make the records display properly } ##################################################################### # Add the following subroutine to html.pl 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; if ($prev_hit) { $previous = qq~<$font>Previous~; } else { $previous = " "; } if ($next_hit <= $db_total_hits) { $next = qq~<$font>Next~; } 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~<$font>Back to record list~; # print out the links print qq|
$previous $next
$list
<$font>Record $nh of $db_total_hits
|; } # Below is where you define your form. # <-- Start of record display --> my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399'; print qq|
<$font_color>ID: <$font>$rec{'ID'}
<$font_color>Title: <$font>$rec{'Title'}
<$font_color>URL: <$font>$rec{'URL'}
<$font_color>Type: <$font>$rec{'Type'}
<$font_color>Date: <$font>$rec{'Date'}
<$font_color>Category: <$font>$rec{'Category'}
<$font_color>Description: <$font>$rec{'Description'}
<$font_color>Validated: <$font>$rec{'Validated'}
<$font_color>Popular: <$font>$rec{'Popular'}
|; # <-- End of record display --> } ##################################################################### # Replace the following subroutines in html.pl 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); &html_print_headers; print qq| $html_title: Search Results.
$html_title: Search Results
|; # Go through each hit and convert the array to hash and send to # html_record for printing. if ($maxhits == 1) { &html_record_long(&array_to_hash(0, @hits)); } else { print qq|

<$font>Your search returned $db_total_hits matches.|; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } $rec_count = 1; print ""; for (0 .. $numhits - 1) { print ""; &html_record (&array_to_hash($_, @hits)); print ""; ++$rec_count; } print "
"; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits";} } &html_footer; print qq| |; } sub html_delete_form { # -------------------------------------------------------- # The user has searched the database for deletion and must now # pick which records to delete from the records returned. This page # should produce a checkbox with name=ID value=delete for each record. # We have to do a little work to convert the array @hits that contains # the search results to a hash for printing. my ($status, @hits) = &query("mod"); my ($numhits) = ($#hits+1) / ($#db_cols+1); my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits); my (%tmp); &html_print_headers; print qq| $html_title: Delete Record(s).

$html_title: Delete Record(s)
|; if ($status ne "ok") { # There was an error searching! print qq|

<$font_error>Error: $status

|; } else { print qq|
|; # Go through each hit and convert the array to hash and send to # html_record for printing. Also add a checkbox with name=key and value=delete. if (($db_total_hits == 1) || ($maxhits == 1)) { print qq|

<$font> If you would like to delete this record, check the box and then press "Delete Records":|; %tmp = &array_to_hash(0, @hits); print qq||; &html_record_long(&array_to_hash(0, @hits)); print qq|
|; } else { print qq|

<$font> Check which records you wish to delete and then press "Delete Records":
Your search returned $db_total_hits matches. |; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } $rec_count = 1; print ""; for (0 .. $numhits - 1) { %tmp = &array_to_hash($_, @hits); print qq||; &html_record (%tmp); print ""; ++$rec_count; } print "
"; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } } print qq|

|; } &html_footer; print qq| |; } sub html_modify_form { # -------------------------------------------------------- # The user has searched the database for modification and must now # pick which record to modify from the records returned. This page # should produce a radio button with name=modify value=ID for each record. # We have to do a little work to convert the array @hits that contains # the search results to a hash for printing. my (%tmp); my ($status, @hits) = &query("mod"); my ($numhits) = ($#hits+1) / ($#db_cols+1); if (($numhits == 1) and !$in{'nh'}) { $in{'modify'} = $hits[$db_key_pos]; &html_modify_form_record(); return; } my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits); &html_print_headers; print qq| $html_title: Modify Record.
$html_title: Modify Record
|; if ($status ne "ok") { # Error searching database! print qq|

<$font_error>Error: $status|; } else { print qq|

|; # 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. print qq|

<$font> Check which record you wish to modify and then press "Modify Records":
Your search returned $db_total_hits matches. |; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } $rec_count = 1; print ""; for (0 .. $numhits - 1) { %tmp = &array_to_hash($_, @hits); print qq||; &html_record (%tmp); print ""; ++$rec_count; } print "
"; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } } print qq|

|; &html_footer; print qq| |; } ##################################################################### # In sub html_add_success and sub html_modify_success, change &html_record(&get_record($in{$db_key})); # to &html_record_long(&get_record($in{$db_key}));