I'm trying to install the "List Categories" mod, but I keep getting "DBMan Error" messages. I've added the needed subroutine to db.cgi, and I've modified the lines in the mod as listed in the comments.
I'm trying to add it to he html_record_ssi page, but I'm not sure where to put it. Here is the original code:
#---------------------------------------------------
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
@lines = <DB>;
close DB;
$in{'mh'} = $#lines;
my (%rec) = @_;
my $font = 'font size=2';
my $font_tiny = 'font size=1';
print qq|
<$font><a href="$db_script_link_url&view_records=1&Artist=$rec{'Artist'}" target="_top">$rec{'Artist'}</a></font><br>
|;
}
How do I add this code in there?
#### In the line below, replace 'Category' with the name of your field.
if ($db_cols[$i] eq "Artist" ) {
$fieldnum = $i; $found = 1;
last;
}
}
if ($found) {
open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
#### if you are using the validate records mod, uncomment the following line and replace the "4" with the
#### number of your Validated field
# if ($field[4] eq "Yes") {
++$count{$fields[$i]};
if (!(grep $_ eq $fields[$fieldnum], @selectfields)) {
push (@selectfields, $fields[$fieldnum]);
}
#### if you are using the validate records mod, uncomment the following line
# }
}
close DB;
foreach $option (sort @options) {
unless ($count{$option}) {
$count{$option} = '0';
}
$encoded = &urlencode($option);
#### if you only want to list categories that have matching entries, uncomment the following line
# if ($count{$option} ne '0') {
#### In the line below, replace 'Category' with the name of your field.
print qq|
<a href="$db_script_link_url&Artist=$encoded&view_records=1">$option</a> ($count{$option})<BR>
|;
#### if you only want to list categories that have matching entries, uncomment the following line
# }
}
}
I'm trying to add it to he html_record_ssi page, but I'm not sure where to put it. Here is the original code:
Code:
sub html_record_ssi { #---------------------------------------------------
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
@lines = <DB>;
close DB;
$in{'mh'} = $#lines;
my (%rec) = @_;
my $font = 'font size=2';
my $font_tiny = 'font size=1';
print qq|
<$font><a href="$db_script_link_url&view_records=1&Artist=$rec{'Artist'}" target="_top">$rec{'Artist'}</a></font><br>
|;
}
How do I add this code in there?
Code:
for ($i = 0; $i <= $#db_cols; $i++) { #### In the line below, replace 'Category' with the name of your field.
if ($db_cols[$i] eq "Artist" ) {
$fieldnum = $i; $found = 1;
last;
}
}
if ($found) {
open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
#### if you are using the validate records mod, uncomment the following line and replace the "4" with the
#### number of your Validated field
# if ($field[4] eq "Yes") {
++$count{$fields[$i]};
if (!(grep $_ eq $fields[$fieldnum], @selectfields)) {
push (@selectfields, $fields[$fieldnum]);
}
#### if you are using the validate records mod, uncomment the following line
# }
}
close DB;
foreach $option (sort @options) {
unless ($count{$option}) {
$count{$option} = '0';
}
$encoded = &urlencode($option);
#### if you only want to list categories that have matching entries, uncomment the following line
# if ($count{$option} ne '0') {
#### In the line below, replace 'Category' with the name of your field.
print qq|
<a href="$db_script_link_url&Artist=$encoded&view_records=1">$option</a> ($count{$option})<BR>
|;
#### if you only want to list categories that have matching entries, uncomment the following line
# }
}
}