Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Category Drop Down

Quote Reply
Category Drop Down
Hi :o)

I'd like to offer my visitors a category drop down after they've added a resource, in add_success.html... so they don't have to go Home and start all over... but I can't figure out how to do it. <%Category%> just writes the name of the category they submitted to.

I thought that might be it 'cos <%Category%> does generate the drop-down in Add, but I guess I was wrong...

Any help?

--Bri

Quote Reply
Re: Category Drop Down In reply to
Once a category is selected, the generation of the drop down list is suppresed, so that the same tag can be used before/after a selection was made.

You'd need to make a global tag in the build_templates area, that would use this portion of the get-cats routines:

Code:
sub {
if ($CFG->{db_gen_category_list}) {
my $db = $DB->table('Links');
my $html = $DB->html($db, $IN);
my @ids = $IN->param('CatLinks.CategoryID') || $IN->param('ID');
$category = $html->get_all_categories(\@ids, 'CatLinks.CategoryID', 1);
}
return $category;
}
The above is taken from add.cgi, and you can see how at the end, the return parameter is screened to either generate the list, or the selected category.

I tried to get more information:

Code:
HTML
To get an html object for generating forms and html output, you need to pass in the table/relation object you want to work with, and a cgi object:


my $html = $db->html ($table, $cgi);


The html object uses information found in CGI to set values, etc. See GT::SQL::Display::HTML for more information on how to use a html object.
but the link in the help docs was broken.

Alex can probably give the answer really quickly. I'm still trying to figure out all the dependencies!

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Quote Reply
Re: Category Drop Down In reply to
This looks similar to what I'm trying to do. I would like to have the root category list appear on every sub-category page.
I tried that code, but I can't get it to work right. I'm not sure where to set the RootID, which I guess is 0.

Do you know how I would alter it to always display the root categoies list? Or is there another way to get all of the root categories to be shown on any page?

Bryan

Quote Reply
Re: Category Drop Down In reply to
OK, then, thanks :o)

Alex? Any thoughts on this?

Quote Reply
Re: Category Drop Down In reply to
Guess, I had the same problem...
maybe you try to set option "db_gen_category_list" in Setup->Build to YES
Description says "Generate a category list. If you have a long set of categories, set this to No so that you don't get very large _drop down lists_."
Hope this helps.

Quote Reply
Re: Category Drop Down In reply to
Hi,

I'm not sure about the formatting, but you would need a little code to do this. Add a template global called root_categories with:

Code:
sub {
my $cat_db = $DB->table('Category');
my $sth = $cat_db->select ( { FatherID => 0 } );
my $output = '';
while (my $cat = $sth->fetchrow_hashref) {
my $url = $cat_db->as_url ($cat->{Full_Name});
$output .= "<a href='$url'>$cat->{Name}</a>";
}
return $output;
}
You may want to tweak the formatting somewhat, but this should give you an idea.

Cheers,

Alex

--
Gossamer Threads Inc.