Gossamer Forum
Home : Products : DBMan : Customization :

Re: sub-categories mod probs..

Quote Reply
Re: sub-categories mod probs.. In reply to
here's what I added to the db.cgi file -

sub urlencode {
# --------------------------------------------------------
# Escapes a string to make it suitable for printing as a URL.
#
my($toencode) = shift;
$toencode =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%x",ord($1))/eg;
return $toencode;

and also -

# Main Menu. Check to see what the user requested, then, if he has permission for that
# request, do it. Otherwise send the user off to an unauthorized request page.

elsif ($in{'view_subcats'}) { if ($per_view) { &html_view_subcats; } else { &html_unauth; } }

to the html.pl I added -

sub html_print_headers {
# --------------------------------------------------------
# Print out the headers if they haven't already been printed.

if (!$html_headers_printed) {
print "Content-type: text/html\n\n";
$html_headers_printed = 1;
}
}
1;

and also -

sub html_view_subcats {
# --------------------------------------------------------

#### In the line below, replace 'Category' with the name of your category field.
$cat_field = "Category";

#### In the line below, replace 'Subcategory' with the name of your subcategory field.
$subcat_field="Subcategory";

&html_print_headers;
print qq|
<html><head><title>$html_title: in{$cat_field}</title></head>

<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: $in{$cat_field}</b></font> </td></tr>
<tr><td><p><center><$font_title><b>$in{$cat_field}</b></font> </center>

|;

for ($i = 0; $i <= $#db_cols; $i ) {
if ($db_cols[$i] eq $cat_field ) {
$fieldnum1 = $i; $found1 = 1;
}
if ($db_cols[$i] eq $subcat_field ) {
$fieldnum2 = $i; $found2 = 1;
}
}

if ($found1 && $found2) {
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 ($fields[$fieldnum1] eq $in{$cat_field}) {
$count_cat{$fields[$fieldnum2]};
}
}
close DB;
foreach $option (sort keys %count_cat) {
$encoded = &urlencode($option);
$encoded2 = &urlencode($in{$cat_field});
print qq|
<a href="$db_script_link_url&$cat_field=$encoded2&$subcat_field=$encoded&view_records=1">$option</a> ($count_cat{$option})<BR>
|;
}
}
&html_footer;
print qq|
</td></tr></table></center></body></html> |;
}

and also -

sub html_home {
# --------------------------------------------------------
# The database manager home page.

&html_print_headers;
print qq|
<html><head><title>$html_title: Main Menu.</title></head>
<body bgcolor="#DDDDDD">
<center><table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF"><b>$html_title: Main Menu</b></td></tr> <tr><td>

#### In the line below, replace 'Category' with the name of your category field.
$cat_field = "Category";

for ($i = 0; $i <= $#db_cols; $i ) {
if ($db_cols[$i] eq $cat_field ) {
$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);
$count{$fields[$fieldnum]};
}
close DB;

foreach $option (sort keys %count) {
$encoded = &urlencode($option);
print qq|
<a href="$db_script_link_url&$cat_field=$encoded&view_subcats=1">$option</a> ($count{$option})<BR>
|;
}
}

all these changes were suggested in http://www.jpdeni.com/dbman/Mods/listcategories9.txt

I still can't figure out whats wrong....
Subject Author Views Date
Thread sub-categories mod probs.. blinktag 2145 Mar 24, 2001, 12:33 PM
Thread Re: sub-categories mod probs..
vampy 2097 Mar 24, 2001, 9:16 PM
Thread Re: sub-categories mod probs..
blinktag 2077 Mar 25, 2001, 5:34 AM
Thread Re: sub-categories mod probs..
vampy 2080 Mar 25, 2001, 5:49 AM
Thread Re: sub-categories mod probs..
blinktag 2078 Mar 28, 2001, 11:43 AM
Thread Post deleted by LoisC
Paul 2068 Mar 28, 2001, 11:48 AM
Thread Re: sub-categories mod probs..
blinktag 2081 Mar 28, 2001, 11:58 AM
Post Re: sub-categories mod probs..
Karen 2048 Mar 28, 2001, 3:21 PM
Post Re: sub-categories mod probs..
vampy 2058 Mar 28, 2001, 5:22 PM