Hi there ^_^ ,
I have a global here that might be able to help.
category_selector
Code:
sub {
my $catid = shift;
my $return_cats = qq|<select name="CatLinks.CategoryID">|;
$return_cats .= "<option></option>";
$return_cats .= getChildren($catid);
$return_cats .= "</select>";
return $return_cats ;
sub getChildren{
my $catid = shift;
my $table = $DB->table('Category');
my $return = "";
$table->select_options ('ORDER BY Full_Name ASC');
my $cond = GT::SQL::Condition->new('FatherID','=',$catid);
my $sth = $table->select( $cond );
while (my $hit = $sth->fetchrow_hashref) {
$return .= "<option value=\"" . $hit->{ID} . "\"";
$return .= ">" . $hit->{Full_Name} . "</option>";
$return .= getChildren($hit->{ID});
}
return $return;
}
}
This should generate a selectbox of the selected category and its children.
You can use it like this: <%category_selector($ID_of_top_category)%>
Just replace "$ID_of_top_category" with the id of the category you want to be loaded.
A word of warning though... the select box is generated using recursion, and I haven't done that in a while.
The global is also not tested... yet anyway. Feel free to modify it as you wish, as it doesn't seem to be precisely what you are looking for...
Hope it helps ^_^
Sacrifice is not about what you lose,
it is about what you gain in the process.