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.
Mar 23, 2001, 3:51 AM
Veteran / Moderator (1203 posts)
Mar 23, 2001, 3:51 AM
Post #3 of 15
Views: 4059
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
$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
Mar 23, 2001, 4:04 AM
Veteran / Moderator (1203 posts)
Mar 23, 2001, 4:04 AM
Post #4 of 15
Views: 4042
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
<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
Mar 23, 2001, 4:22 AM
Veteran / Moderator (1203 posts)
Mar 23, 2001, 4:22 AM
Post #6 of 15
Views: 4052
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
#!/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
Mar 23, 2001, 4:32 AM
Enthusiast (720 posts)
Mar 23, 2001, 4:32 AM
Post #7 of 15
Views: 4039
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
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
Mar 23, 2001, 5:24 PM
Enthusiast (720 posts)
Mar 23, 2001, 5:24 PM
Post #8 of 15
Views: 4030
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
# --------------------------------------------------------
# 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
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 thisCode:
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
} );
}
Mar 23, 2001, 5:41 PM
Veteran (19537 posts)
Mar 23, 2001, 5:41 PM
Post #9 of 15
Views: 4030
You will need to edit sub build_select_field
Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Mar 24, 2001, 5:54 AM
Veteran / Moderator (1203 posts)
Mar 24, 2001, 5:54 AM
Post #11 of 15
Views: 3997
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
Good Luck!
Glenn
http://cgi-resource.co.uk/pages/links2mods.shtml
Mar 24, 2001, 5:57 AM
Veteran (19537 posts)
Mar 24, 2001, 5:57 AM
Post #12 of 15
Views: 3993
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/
Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Mar 24, 2001, 8:51 AM
Enthusiast (720 posts)
Mar 24, 2001, 8:51 AM
Post #13 of 15
Views: 3994
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
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
Mar 24, 2001, 9:41 AM
Veteran (19537 posts)
Mar 24, 2001, 9:41 AM
Post #14 of 15
Views: 4003
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/
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/