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

dropdown menu of subscategories global?

Quote Reply
dropdown menu of subscategories global?
Howdie,

Is there already a global floating around here that will create a dropdown menu of all subcats within a category?

What I am hoping to do is within each category and subcat, put a global tag that will pull all the subcats from within the parent category into a dropdown menu.

so, let's say that the top category is: Apartments
and subcats are: 1 bedroom, 2 bedroom, 3 bedroom

So, if I place this tag on category.html, no matter which subcat you are in, the dropdown will show:
1 bedroom
2 bedroom
3 bedroom

I'd also want it to show subcats of subcats, too.

Anyone up for writing a global? Smile Thanks!

Last edited by:

Evoir: Jun 12, 2003, 11:41 AM
Post deleted by Clint In reply to

Last edited by:

Clint: Jun 13, 2003, 2:16 AM
Quote Reply
Re: [Evoir] dropdown menu of subscategories global? In reply to
Frown Can anyone steer me in the right direction here?
Quote Reply
Re: [Evoir] dropdown menu of subscategories global? In reply to
The problem is that each subcategory is held in lsql_Category, with FatherID assigned to each category (set to 0 if its a root category). Writing a global to do as you are asking would put CPU usage up quite a bit. A simple global that would just bring up a list of sub-categories within a category is easy, but when you try and go another subcategory deep, it is a lot harder.

i.e this would be ok;

Main category: Test
Test> Sub 1
Test> Sub 2
Test> Sub 3
Test> Sub 4

...harder;

Main category: Test
Test> Sub 1
Test> Sub 1 > Sub-Sub 1
Test> Sub 1 > Sub-Sub 2
Test> Sub 2
Test> Sub 2 > Sub-Sub 1
Test> Sub 2 > Sub-Sub 2
Test> Sub 3
Test> Sub 3 > Sub-Sub 1
Test> Sub 3 > Sub-Sub 2
Test> Sub 4
Test> Sub 4 > Sub-Sub 1
Test> Sub 4 > Sub-Sub 2

Do you see what I mean?

Cheers

Andy (mod)
andy@ultranerds.co.uk
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] dropdown menu of subscategories global? In reply to
Thanks for explaining Andy. So, would it be possible to have a drop down menu that shows the only the subcats within a category?

For example, if the main categories are Condos, Houses, Commercial Spaces

And let's say there are 6 subcats under Condos. I'd like th pull down to show only those 6 subcats of Condos. How possible, difficult would this be? Has there already been a global written for this? If so, can you point me in the right direction? If it is doable and not too hard, can you suggest how to make it work? Thanks again!
Quote Reply
Re: [Evoir] dropdown menu of subscategories global? In reply to
Something like this should work;

Code:
sub {

# create the root category dropdowns...

my $table = $DB->table('Category');
my $return;
my $cat_ID = shift;

$return = "<select name=\"myjumpbox\"><option selected>Short List...</option>";

$table->select_options ('ORDER BY Name ASC');
my $sth = $table->select( GT::SQL::Condition->new( 'FatherID', '=', $cat_ID ) );
while (my $hit = $sth->fetchrow_hashref) {

my $Title = $hit->{Name};
$Full_Name =~+ s/\s/_/g;
my $ID = $hit-{ID];
$return .= "<option value=\"$ID\">$Title</option>";

}

$return .= "</select></form>";

return $return;

}

Call it with <%global_name($FatherID)%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
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: [Evoir] dropdown menu of subscategories global? In reply to
I think this is similar to what you want (note the extra ~ which needs removing).

http://www.gossamer-threads.com/...i?post=234060#234060