Gossamer Forum
Home : Products : Links 2.0 : Customization :

Category Menu Every Where

Quote Reply
Category Menu Every Where
Hello all,

I found the mod 'Category Menu' by Glennu, this will give a list/menu of top level categories anywhere on templates, but is it possible if ppl click into one of the category, it will highlight the category name, for example the photo galleries at http://www.washingtonpost.com/...tion/photogalleries/, look at into the right window the 'Photo Galleries' was highlight , is it possible ? Sorry to my english.

Please help and thanks

----------------------------------------------------------
Category Menu Everywhere Mods
In db_utils.pl add the following sub:

sub menu {
# --------------------------------------------------------
#
my (%c, @fields);
open (DB, "<$db_category_name") or &cgierr("unable to open $db_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
@fields = &split_decode ($_);

$c{$fields[$db_main_category]}++;
}
close DB;

foreach $field (sort keys %c) {

if ($field =~ m,^([^/]*)$,) {
$field2 = &build_clean($field);
$category_list .= qq|<a href= "$build_root_url/$field">$field2</a>
|;
}
}

return $category_list;
}

Then in sub html templates add in the globals section at the very top:

menu => &menu,

Then just add <%menu%> where ever you want the list of category links to appear.
http://

Last edited by:

reenee: Sep 12, 2001, 9:44 AM
Quote Reply
Re: [reenee] Category Menu Every Where In reply to
Just in case anybody wants to use the code... pls add the following in red.

Code:

sub menu {
# --------------------------------------------------------
#

$category_list = '';
my (%c, @fields);
open (DB, "<$db_category_name") or &cgierr("unable to open $db_file_name. Reason: $!");


Then in sub html templates add in the globals section at the very top:

menu => /&menu,
Quote Reply
Re: [missguy] Category Menu Every Where In reply to
>>menu => /&menu,<<

Thats not right :)

Use:

menu => &menu,
Quote Reply
Re: [RedRum] Category Menu Every Where In reply to
hehe... that and it pointless to have $category_list = ''; if you aren't using my or local or have that line inside some sort of block code. (yes, Links 2.0 is full of that kind of code...)

--Philip
Links 2.0 moderator
Quote Reply
Re: [ThatPerson1024] Category Menu Every Where In reply to
Hmmm

I had to add in the '/' for it to work (to build) and i added in the $category_list = ''; because on some pages... the dir list gets repeated. of course we can use 'my' or 'local' but i just plugging in the holes to the mod.

Maybe if any1 faces any problems can try out my suggestions. :P

merry xmas