i have code to print out a select name form thing and print out the names of categories. I have a field in the category definition file called Edit. What i want is that if edit is selected 'Yes', leave the category in and if its no, take it out.
This it build_select_field from links.
# --------------------------------------------------------
# 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 (",", &emcategory_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) {
if ($field =~ m/\@$/) {
$field =~ s/.*(\w+)(?=\@$)\@$//g;
}
$values{$field} ?
($output .= "\n") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
return $output;
}
I have it now so that categories with @ at the end are taken out, but can't get ones with edit as No.
This it build_select_field from links.
Code:
sub build_select_field3 { # --------------------------------------------------------
# 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 (",", &emcategory_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) {
if ($field =~ m/\@$/) {
$field =~ s/.*(\w+)(?=\@$)\@$//g;
}
$values{$field} ?
($output .= "\n") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
return $output;
}
I have it now so that categories with @ at the end are taken out, but can't get ones with edit as No.