Gossamer Forum
Quote Reply
Menu bar
How can I create a list of categories in a menu bar. To see what I mean, www.studentrewards.co.uk. I still want to keep the existing category listing.

Quote Reply
Re: Menu bar In reply to
one way to get a menu is by adding the hopto mod. try searching the customization forum for hop to dropdown. I installed it and it works great. But it takes up some space since all the categories end up in the html.

Gene
Quote Reply
Re: Menu bar In reply to
A quick easy way to do it is to go into sub category in site_html_templates.pl and add the following:

$categorydrop = &build_select_field ("Category", "$in{'Category'}");



Then in the bottom of the sub add:

categorydrop => $categorydrop,

Thenb in category.html add <%categorydrop%>

That'll get you your category select box. Make a small cgi script to take the user to the selected category. Then just put it inside a form and link to that cgi script.

Only thing is it takes all the categories including subcategories. Good if you only have a few categories, bad if you have loads of categories.


Good Luck!

Glenn
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Menu bar In reply to
In your category.html put:

<form action="<%db_cgi_url%>/go.cgi" method="GET">
<%categorydrop%><input type=submit value="Go!" name=submit>
</form>

In the cgi script put:

my %in = &parse_form();
my ($category);

$category = $in{'Category'};

print "Location: $db_cgi_url/$category\n\n" ;


Good Luck!

Glenn
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Menu bar In reply to
Hmmm...Intriguing. And what would that small cgi scrip look like?

Gene
Quote Reply
Re: Menu bar In reply to
Like this:

#!/usr/bin/perl

require "admin/links.cfg";
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";

my %in = &parse_form();
my ($category);

$category = $in{'Category'};
print "Location: http://path to links directory/$category\n\n" ;


Works fine and I'll be using a drop down box similar to this on a site I have in mind as I'll only have a total of about 10 categories.



Good Luck!

Glenn
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Menu bar In reply to
Glenn, you are just toooooo much. Wish I knew this perl stuff like you ...!

I'll work on this later today and let you know how it works.

Thanks...!

And that's not to forget the others on this forum like eliot, paul, thomas, etc.

Alex should give all of you guys some sort of pay for all the work you do.

Better quit before I get maudlin

Gene
Quote Reply
Re: Menu bar In reply to
HotD*mn...!

That works just like a charm...!

That was much simpler than the hopto mod I referenced. Still, it fills up a little less than half of an html page but that is much less than what I had before.

The box defaults to a couple of dashes....is there a way to change that...?

Again....Thanks

Code:
BTW, for those who want to use this, the sub that Glen say to modify is the site_html_category. Will look something like this
Code:
sub site_html_category {
# --------------------------------------------------------
# This rountine will build a page based for the current category.
#Glenn's hopto mod
$categorydrop = &build_select_field ("Category", "$in{'Category'}");

return &load_template ( 'category.html', {
date => $date,
time => $time,
category => $category,
links => $links,
ETC...
ETC...
categorydrop => $categorydrop,
category_title => $category_title,
AltCategories => AltCategories,
%globals
} );
}
Gene
Quote Reply
Re: Menu bar In reply to
You will need to edit sub build_select_field

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Menu bar In reply to
Hmmm....I see.

but is there a way to use an if statement to have more than one default.

I guess I could just clone the sub build_select_field and assign it a new name and call that name. Too many calls to build_select_fields to do something else, I guess.

Thanks for the tip....!


Gene
Quote Reply
Re: Menu bar In reply to
Yeah if you want to alter it your best to create a second sub build_select_field2 and use that instead. Because the select field sub is used to build the other drop down boxes such as the ones found in admin.

Good Luck!

Glenn
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Menu bar In reply to
I provided codes to customize the auto-generated drop down box in another thread so if you search Links2 Customization forum for something like search thiscat you should find it.

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Menu bar In reply to
OK, created the clone and changed the default select to Select a Category. However, if they just click on GO without changing the default, I get "page not found" since I don't have a Select a Category category. Is there any way to correct that - modify the calling cgi?

Is there a way to put the

$categorydrop = &build_select_field_ddmenu ("Category", "$in{'Category'}");

which is currently located in the sub site_html_category, into some sort of global definitions so that it could be available to other routines....?

And what would I need to do to add the category drop down box so that I can use it in the search feature????

Gene
Quote Reply
Re: Menu bar In reply to
As I said, I provided example code for this enabling you to add the select list to search.html. There is some code to be added to search.cgi that was created by another user.

http://gossamer-threads.com/...ew=&sb=&vc=1

Example.....

http://www.perlmad.com/cgi-bin/search.cgi

The get the select list to show on any page, make $categorydrop into a global.

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Menu bar In reply to
Thanks...!! I really appreciate it.

I'll work on it....

Gene