Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Re: Categories in a dropdown box?

Quote Reply
Re: Categories in a dropdown box? In reply to
Not out of the box no. You could do something like:

Code:
sub category_dropdown {
# -----------------------------------------
# Generate a dropdown list of categories.
#
my $db = new Links: BSQL $LINKS{admin_root_path} . "/defs/Category.def";
my $cats = $db->query ( { ID => '*', sb => 'Name' } );
my $output = '';
if ($db->hits) {
$output = '<SELECT NAME="Category">
foreach my $cat (@$cats) {
$cat = $db->array_to_hash($cat);
$output .= "<OPTION>" . $cat->{Name};
}
$output .= "</SELECT>";
}
else {
$output = "Sorry, we don't have any categories.";
}
return $output;
}

and put that in HTML_Templates.pm. Then add category_list => \&category_dropdown in your GLOBALS list. Then you can use <%category_list%> wherever you like to generate a select list.

Hope that helps,

Alex
Subject Author Views Date
Thread Categories in a dropdown box? ekaram 2557 Dec 28, 1999, 6:45 PM
Post Re: Categories in a dropdown box?
Alex 2494 Dec 29, 1999, 7:56 AM
Post Re: Categories in a dropdown box?
Martin Kjeldsen 2490 Jan 20, 2000, 2:47 AM
Post Re: Categories in a dropdown box?
Alex 2491 Jan 21, 2000, 10:50 AM
Post Re: Categories in a dropdown box?
klangan 2490 Feb 1, 2000, 3:53 PM
Post Re: Categories in a dropdown box?
Dan Kaplan 2481 Feb 13, 2000, 6:55 AM
Post Re: Categories in a dropdown box?
Dan Kaplan 2485 Feb 13, 2000, 3:21 PM