Hi
I installed the multi-cat mod/templates a long time ago, but it would never build a MULTIPLE select box for AltCategories on add.html, modify.html. It only builds a single.
In db.utils, I have:
# --------------------------------------------------------
# Builds a SELECT field based on information found
# in the database definition.
#
my ($column, $value, $name, $mult) = @_;
my ($size, %values);
$name | | ($name = $column);
$size | | ($size = 1);
if (! exists $db_select_fields{$column}) {
$db_select_fields{$db_cols[$db_category]} = $db_select_fields{'Mult-Related'} = join (",", &category_list);
}
if (! exists $db_select_fields{$column} && $column eq "AltCategories" && exists $db_select_fields{'Category'}) {
$db_select_fields{$db_cols[$db_alt_cat]} = $db_select_fields{'Mult-AltCategories'} = $db_select_fields{'Category'}}
elsif (! exists $db_select_fields{$column} && $column eq "AltCategories" && ! exists $db_select_fields{'Category'}) {
$db_select_fields{$db_cols[$db_alt_cat]} = $db_select_fields{'Mult-AltCategories'} = join (",", &category_list);}
if ($mult) {
@fields = split (/\,/, $db_select_fields{"Mult-$column"});
%values = map { $_ => 1 } split (/\Q$db_delim\E/, $value);
}
else {
@fields = split (/\,/, $db_select_fields{$column});
$values{$value}++;
}
($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!";
$output = qq|<SELECT NAME="$name" $mult SIZE=$size><OPTION>---|;
foreach $field (@fields) {
$values{$field} ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
return $output;
}
and
#--------------------------------------------------------
# Builds a record form based on the config information.
#
my ($output, $field, $multiple, $name);
($_[0] eq "multiple") and ($multiple = 1) and shift;
my (%rec) = @_;
$output = "<p><table border=1>";
# Go through a little hoops to only load category list when absolutely neccessary.
if ($in{'db'} eq 'links') {
exists $db_select_fields{$db_cols[$db_category]}
or ($db_select_fields{$db_cols[$db_category]} = join (",", &category_list));
($db_select_fields{$db_cols[$db_alt]} = $db_select_fields{'Mult-AltCategories'} = join (",", &category_list));
}
else {
$db_select_fields{'Related'} or
($db_select_fields{'Related'} = $db_select_fields{'Mult-Related'} = join ",", &category_list);
}
foreach $field (@db_cols) {
# Set the field name to field-key if we are doing multiple forms.
$multiple ? ($name = "$field-$rec{$db_key}") : ($name = $field);
if ($db_select_fields{"Mult-$field"}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name, "MULTIPLE SIZE=5") . "</td></tr>\n";}
elsif ($db_select_fields{$field}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_radio_fields{$field}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_radio_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_checkbox_fields{$field}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_form_len{$field} =~
/(\d+)x(\d+)/) {$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><textarea wrap="virtual" name="$name" cols="$1" rows="$2">$rec{$field}</textarea></td></tr>\n~;}
elsif ($db_form_len{$field} == -1) {$output = qq~<input type=hidden name="$field" value="$rec{$field}">\n$output~; }
else {$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~;}
}
$output .= "</table></p>\n";
return $output;
}
In site_html_templates.pl, I have:
# --------------------------------------------------------
# This routine determines how the add form page will look like.
#
&html_print_headers;
my $category = shift;
if (!@exclude_categories) {
my $category = &build_select_field ("Category", "$in{'Category'}");
my $altcategories = &build_select_field ("AltCategories", "$in{'AltCategories'}", "AltCategories", "MULTIPLE Size=3");
}
else {
($category = &get_cat_select_list);
($altcategories = &get_altcat_select_list);
}
print &load_template ('add.html', {
AltCategories => $altcategories,
Category => $category,
category => $category,
%globals
});
}
And, on add.html, etc., I have:
<td align="right" valign="top" width="30%"><b><font size="2" face="Tahoma">Additional Category:</font></b></td>
<td align="left" width="69%"><font face="Arial" size="2">
<%AltCategories%>
</font></td>
</tr>
I've tried these threads:
www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/000960.html
www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/002153.html
www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/003679.html
But, still, I can't figure out the bug. If anyone has any ideas, I would be very grateful for any help. Sorry about all the code, I've tried everything I can think of.
Thanks.
[This message has been edited by DogTags (edited January 19, 2000).]
I installed the multi-cat mod/templates a long time ago, but it would never build a MULTIPLE select box for AltCategories on add.html, modify.html. It only builds a single.
In db.utils, I have:
Code:
sub build_select_field { # --------------------------------------------------------
# Builds a SELECT field based on information found
# in the database definition.
#
my ($column, $value, $name, $mult) = @_;
my ($size, %values);
$name | | ($name = $column);
$size | | ($size = 1);
if (! exists $db_select_fields{$column}) {
$db_select_fields{$db_cols[$db_category]} = $db_select_fields{'Mult-Related'} = join (",", &category_list);
}
if (! exists $db_select_fields{$column} && $column eq "AltCategories" && exists $db_select_fields{'Category'}) {
$db_select_fields{$db_cols[$db_alt_cat]} = $db_select_fields{'Mult-AltCategories'} = $db_select_fields{'Category'}}
elsif (! exists $db_select_fields{$column} && $column eq "AltCategories" && ! exists $db_select_fields{'Category'}) {
$db_select_fields{$db_cols[$db_alt_cat]} = $db_select_fields{'Mult-AltCategories'} = join (",", &category_list);}
if ($mult) {
@fields = split (/\,/, $db_select_fields{"Mult-$column"});
%values = map { $_ => 1 } split (/\Q$db_delim\E/, $value);
}
else {
@fields = split (/\,/, $db_select_fields{$column});
$values{$value}++;
}
($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!";
$output = qq|<SELECT NAME="$name" $mult SIZE=$size><OPTION>---|;
foreach $field (@fields) {
$values{$field} ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
return $output;
}
and
Code:
sub build_html_record_form { #--------------------------------------------------------
# Builds a record form based on the config information.
#
my ($output, $field, $multiple, $name);
($_[0] eq "multiple") and ($multiple = 1) and shift;
my (%rec) = @_;
$output = "<p><table border=1>";
# Go through a little hoops to only load category list when absolutely neccessary.
if ($in{'db'} eq 'links') {
exists $db_select_fields{$db_cols[$db_category]}
or ($db_select_fields{$db_cols[$db_category]} = join (",", &category_list));
($db_select_fields{$db_cols[$db_alt]} = $db_select_fields{'Mult-AltCategories'} = join (",", &category_list));
}
else {
$db_select_fields{'Related'} or
($db_select_fields{'Related'} = $db_select_fields{'Mult-Related'} = join ",", &category_list);
}
foreach $field (@db_cols) {
# Set the field name to field-key if we are doing multiple forms.
$multiple ? ($name = "$field-$rec{$db_key}") : ($name = $field);
if ($db_select_fields{"Mult-$field"}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name, "MULTIPLE SIZE=5") . "</td></tr>\n";}
elsif ($db_select_fields{$field}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_radio_fields{$field}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_radio_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_checkbox_fields{$field}) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_form_len{$field} =~
/(\d+)x(\d+)/) {$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><textarea wrap="virtual" name="$name" cols="$1" rows="$2">$rec{$field}</textarea></td></tr>\n~;}
elsif ($db_form_len{$field} == -1) {$output = qq~<input type=hidden name="$field" value="$rec{$field}">\n$output~; }
else {$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~;}
}
$output .= "</table></p>\n";
return $output;
}
In site_html_templates.pl, I have:
Code:
sub site_html_add_form { # --------------------------------------------------------
# This routine determines how the add form page will look like.
#
&html_print_headers;
my $category = shift;
if (!@exclude_categories) {
my $category = &build_select_field ("Category", "$in{'Category'}");
my $altcategories = &build_select_field ("AltCategories", "$in{'AltCategories'}", "AltCategories", "MULTIPLE Size=3");
}
else {
($category = &get_cat_select_list);
($altcategories = &get_altcat_select_list);
}
print &load_template ('add.html', {
AltCategories => $altcategories,
Category => $category,
category => $category,
%globals
});
}
And, on add.html, etc., I have:
Code:
<tr> <td align="right" valign="top" width="30%"><b><font size="2" face="Tahoma">Additional Category:</font></b></td>
<td align="left" width="69%"><font face="Arial" size="2">
<%AltCategories%>
</font></td>
</tr>
I've tried these threads:
www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/000960.html
www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/002153.html
www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/003679.html
But, still, I can't figure out the bug. If anyone has any ideas, I would be very grateful for any help. Sorry about all the code, I've tried everything I can think of.
Thanks.
[This message has been edited by DogTags (edited January 19, 2000).]