Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Conditional Category Dropdowns????

Quote Reply
Conditional Category Dropdowns????
Hi all,

I'm beginning to get a REALLY BIG directory structure. The select a category dropdown in the add and modify forms are beginning to get quite LONG! I'm looking for a solution to what seems to me to be a usability problem.

My set up has 4 major categories. Under each of these there are many subcategories. One solution would be to have a custom add forms each with a custom dropdown perhaps coded for by a global. Unfortunately, the project requires that people are able to submit to multiple major categories upon submission. I have the multiple category select mod working beautifully. No I just need to figure out a way to make this dropdown more user friendly but still allow multiple selections. Anybody care to throw out some suggestions? One multiselect dropdown per major category? (seems like a programming nightmare). Other ideas?

Quote Reply
Re: [Swaylock] Conditional Category Dropdowns???? In reply to
For the user side of things (i.e add.cgi)...you could create the following global...call it 'dynamic_cat_list'

sub {
my $CatID = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options ("ORDER BY Full_Name DESC");
my $sth = $cat_db->select ( { FatherID => $CatID });
my $output = '';
while (my $cat = $sth->fetchrow_hashref) {
$output .= "<option value='$cat->{ID}'>$cat->{Name}</option>";
return $output;

Now, in your add.html template, use something like;

<%if ID == 4%>
<%elsif ID == 5%>

Thats just an example... the numbers in the ()'s are the categories ID number (the root one you are trying to list subcateories off).

Hopefully it will work Smile

Andy (mod)
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Conditional Category Dropdowns???? In reply to

VERY COOL! Thanks so much for that elegant solution. I'll give it a try and let you know how it goes.