Gossamer Forum
Home : Products : DBMan : Customization :

sub-categories mod probs..

Quote Reply
sub-categories mod probs..
Hi,

I've been trying to get the subcategories mod at -
http://www.jpdeni.com/dbman/Mods/listcategories.html
to Show categories and subcategories on separate pages -
but am getting nowhere - I make the specificied changes in
http://www.jpdeni.com/dbman/Mods/listcategories9.txt
but it doesn't work - is there something else that need to be done before I make the changes suggested in this mod?
it really isn't well explained how to simply get subcategories - can anyone help?

what is the difference between "For use with the "user-friendly" html.pl file " and 'For use with the default html.pl file ' ?
I think Dbman looks like a fantastic bit of software but it really is not well explained how to use it on any website I can find...
I hope someone can help....
Quote Reply
Re: sub-categories mod probs.. In reply to
You need to be more specifc about what is not working. Do you get errors or no results or what. The difference between user-friendly html.pl and default html.pl is as the name suggest the user-friendly html.pl is a modification of the default html.pl that makes it more user-friendly to edit and modify. If you download the DBman package from this site and use that html.pl in that package then you would be using the default html.pl There is difference between the 2 versions and you must ensure that when you use any MODs to read the instructions given in the mod so that you knwo that you did not try to install a mod that will not work with a certain other modfication.

Actually you can check out this fantastic website (No, it's not mine.

http://webmagic.hypermart.net/dbman

It is sort of an archive of all the discussions taken place here but categorised into categories that are self-explantory. As for the usablity of DBMan, I have to say that it is much easier to use and the dicumentation is much better than other free cgi-scripts available on the net. note that this version of DBMan is free and for something that is free, the documentation is good. I have come across some documentations that literary makes you pull out your hairs in bunches. they don't even tell you where to go if you face problems.

Julian
Quote Reply
Re: sub-categories mod probs.. In reply to
thanks for the help.. finally a response from the forum!
I understand the default.html stuff now...
I have made the changes suggested in http://www.jpdeni.com/dbman/Mods/listcategories9.txt but dbman returns with a server error on the home page...
Does anyone have an example of html.pl or db.cgi with the changes they have made to it, that is working?
this would help greatly....
Quote Reply
Re: sub-categories mod probs.. In reply to
Can you post a .txt version of the file that you made the changes to on your website and ensure that others can look at it. This would help us very much in solving problems. Usually, server errors are due to some mistypes. So if you made changes to say html.pl, make a copy of that file but change it to html.txt and put it on your web so that I can have a look. No guarantee.

By the way, because of the amount of messages in the forum it may take some time to response to questions pose. Give it a few days and if you still can't solve the problem just reply to your own message so that your message will move up the thread. I have been in this forum for less than a year and I would say that the response time is good.

Julian
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....
Quote Reply
Post deleted by LoisC In reply to
Quote Reply
Re: sub-categories mod probs.. In reply to
Do you mean the file changes are correct but there may be something wrong with permission or something else?
The default DB before I made these changes worked fine...
Does anyone have sample db.cgi or html.pl files we can view to see correct position of changes made to files?
It would make it easier to find the problem...
Quote Reply
Re: sub-categories mod probs.. In reply to
It makes it easier to find "your" problem if you save "your" file as a text file and upload it to "your" server where it can be viewed using a URL.

Everyone has various customizations etc to their files which may or may not be similar to changes you have made - In order to help find your problem, we need to see your file.

Quote Reply
Re: sub-categories mod probs.. In reply to
Hi! Found your error. Look at the codes for your sub html_home. You forgot to add |; to the line

<b>$html_title: Main Menu</b>
</td></tr>
<tr><td>|;

The |; in red is missing.

You are also missing a }. Add it to the end of the same subroutine.