OOps - did not explain myself correctly... Its not linking, did anyone get it to work?
my $show_count = $_[0];
my $category;
my $db = $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Full_Name','Number_of_Links'] ) || return $GT::SQL::error;
my $back;
while (my ($id,$full_name,$numberoflinks) = $sth->fetchrow_array) {
my $full_name2;
my @cut = split /\//, $full_name;
for (my $i=0; $i < $#cut; $i++) {
$full_name2 .= " ";
}
$full_name2 .= $cut[$#cut];
if ($show_count) {
$full_name2 .= " ($numberoflinks)";
}
$back .= "<option value=\"$id\">$full_name2</option>";
}
my $send_back = qq|<select size="1" name="catid"><option value="">------</option>$back</select>|;
return $send_back;
}
This one works perfect but does not indent the subcategories and I really do like the link count better
my ($category,$output);
my $db = $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name','LIMIT 100') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Full_Name'] ) || return $GT::SQL::error;
$output .= qq|<select name="nnn-DeptSelect" onchange="top.location=this.options[this.selectedIndex].value" size="1">\n|;
$output .= qq|<option selected>Site Categories</option>\n|;
while (my ($id,$full_name) = $sth->fetchrow_array) {
my $safe_full = $full_name;
my @cut = split /\//, $full_name;
my $back = '';
for (my $i=0; $i < $#cut; $i++) {
$back .= q| |;
}
$back .= $cut[$#cut];
$output .= qq|<option value="$CFG->{build_root_url}/| . $db->as_url($safe_full) . qq|">$back</option>|. "\n";
}
$output .= "</select>\n";
return \$output;
}
Thank in advance for any comments or re-writes.
Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Code:
sub { my $show_count = $_[0];
my $category;
my $db = $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Full_Name','Number_of_Links'] ) || return $GT::SQL::error;
my $back;
while (my ($id,$full_name,$numberoflinks) = $sth->fetchrow_array) {
my $full_name2;
my @cut = split /\//, $full_name;
for (my $i=0; $i < $#cut; $i++) {
$full_name2 .= " ";
}
$full_name2 .= $cut[$#cut];
if ($show_count) {
$full_name2 .= " ($numberoflinks)";
}
$back .= "<option value=\"$id\">$full_name2</option>";
}
my $send_back = qq|<select size="1" name="catid"><option value="">------</option>$back</select>|;
return $send_back;
}
This one works perfect but does not indent the subcategories and I really do like the link count better
Code:
sub { my ($category,$output);
my $db = $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name','LIMIT 100') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Full_Name'] ) || return $GT::SQL::error;
$output .= qq|<select name="nnn-DeptSelect" onchange="top.location=this.options[this.selectedIndex].value" size="1">\n|;
$output .= qq|<option selected>Site Categories</option>\n|;
while (my ($id,$full_name) = $sth->fetchrow_array) {
my $safe_full = $full_name;
my @cut = split /\//, $full_name;
my $back = '';
for (my $i=0; $i < $#cut; $i++) {
$back .= q| |;
}
$back .= $cut[$#cut];
$output .= qq|<option value="$CFG->{build_root_url}/| . $db->as_url($safe_full) . qq|">$back</option>|. "\n";
}
$output .= "</select>\n";
return \$output;
}
Thank in advance for any comments or re-writes.
Sandra Roussel
Chonsa Group Design - Fresh Start Housing