Gossamer Forum
Home : Products : DBMan : Customization :

Category mod

Quote Reply
Category mod
Hi there,

I have modify the category mod for listing category's from the database. I want to use this mod to call this with a url inside the browser and not through the menu of dbman or ny using it with SSI. This is working but i have many category's and for this to work i need to build a sub for every different category. Therefore i want to modify the code below so that i can give the necessary information by parameters. To make this work i need to pass 3 parameters: $cat_name, $field and fieldnumber ,and a value for this field like in the script the word sale (see script below)

Is this possible and if so how can i make this.

Thanks for the help
Marcel

sub html_categorie_view {

$cat_name = "merk";

&html_print_headers;

for ($i = 0; $i <= $#db_cols; $i++) {
if ($db_cols[$i] eq "$cat_name") {
$fieldnum = $i; $found = 1;
last;
}
}
if (!$found) {
&cgierr("No $cat_name field defined");
}
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 ($field[10] =~ /sale/) { # Change the 2 to match the field number you want to search
@values = split (/\Q$db_delim\E/o, $fields[$fieldnum]);
foreach $value (@values) {
if (!(grep $_ eq $value, @selectfields)) {
push (@selectfields, $value);
}
++$count{$value};
}
}
}
close DB;

foreach $field (sort @selectfields) {
$sfield = &urlencode($field);
print qq|<FONT SIZE="-1" FACE="Verdana,Tahoma,Arial,Helvetica,sans-serif"><a href="$db_script_link_url&$&view_records=1&ID=*&$cat_name=$sfield&cat_nl=sale&sb=1&so=descend">$field</font></a><br>|;
}
}