Gossamer Forum
Home : Products : Links 2.0 : Customization :

categories list on sub pages

Quote Reply
categories list on sub pages
Is it possible to have the categories list from your homepage
on the inside category/link pages... (like on a sidebar )
simply putting the <%category%> inside doesn't seem to do the trick...



Quote Reply
Re: categories list on sub pages In reply to
There's lots of ways to do this, if you search the forum for hopto or drop down list you'll find some which give a drop down box of categories.



Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: categories list on sub pages In reply to
Here's one way of doing it by using and altering the list cat sub in db_utils. This will give a list of top level categories anywhere on your templates:

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.


Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: categories list on sub pages In reply to
that works great - is it possible to do a menu with sub-categories?

Quote Reply
Re: categories list on sub pages In reply to
Replace:

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

With:

$field2 = &build_clean($field);
$category_list .= qq|<a href= "$build_root_url/$field">$field2</a>
|;







Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: categories list on sub pages In reply to
that doesn't seem to do anything...would I have to start over re-building pages...?
I was hoping to have a menu with sub-cat's only....

Quote Reply
Re: categories list on sub pages In reply to
Yes you will have to rebuild the directory.

The code above will display all categories inc sub categories.

If you want just sub categories replace:

if ($field =~ m,^([^/]*)$,) {

With:

unless ($field =~ m,^([^/]*)$,) {



Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: categories list on sub pages In reply to
that works a treat but it also includes the 'category' name too...
so if you add industry/web it is listed as 'industry_web' rather than just 'web' - is it possible to just have the subcat name on its own?

Quote Reply
Re: categories list on sub pages In reply to
Instead of:

$field2 = &build_clean($field);

Use:

$field2 = &build_clean($1);


Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: categories list on sub pages In reply to
for some reason the menu link urls are there but the actual text for the link doesn't show up- so its invisible effectively...here's the full sub menu routine...

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) {

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


Quote Reply
Re: categories list on sub pages In reply to
any idea why the links wouldn't be showing up?
any help is greatly appreciated....

Quote Reply
Re: categories list on sub pages In reply to
hi glennu, could you take a look at the above problem - i'm sure its something simple - - the url prints ok, but not the actual text for the link...

Quote Reply
Re: categories list on sub pages In reply to
How to integrate Category Menu & nonEnglish Mod, I want to show the menu with nonEnglish menus. ...any ideas

Thanks

Good luck ,

Micheal Chan
Quote Reply
Re: categories list on sub pages In reply to
I tried this too and get the same problem...

Quote Reply
Re: [eightball] categories list on sub pages In reply to
Hi eightball try this you will find its works for what you wish.

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($1); } else { $field2 = &build_clean($subcat); }
$category_list .= qq|<a href= "$build_root_url/$field">$field2</a><br>
|;
}
return $category_list;
}

I hope it helps!Tongue
Quote Reply
Re: [monshow] categories list on sub pages In reply to
To use nonenglish category names, use this:

$field2 = &kategorie_title_mb($field);

in place of the code above. You may need to add the nonenglish mod's subroutine '&kategorie_title_mb' to the bottom of db_utils.pl. (I already had it there, so I'm not sure if it's needed for this hack or not...)


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] categories list on sub pages In reply to
HELPPPPPPPPPPPPPP!

This stuff is great but need help:

I want to build several of these nav bars at one time.

When I try multiple sub routines they just keep adding on to each other.

How would you change the sub routines so you could build several of these nav bars at one time???????????????
-----------------------------------------------------------
Professional Search Engine Marketing by Position Concepts Professional Consulting in SEM, SEO and PPC.
Quote Reply
Re: [poscon] categories list on sub pages In reply to
Not sure what you mean. More than one on each page?


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] categories list on sub pages In reply to
and possible possession all links of the home page in the fund of the page of the categories

thanks
- - - - - - - - - -- - - - - -
DirectoryNautica-Italia
http://www.nauticalink.it
Quote Reply
Re: [glennu] categories list on sub pages In reply to
you excuse but not no understands where I must insert this

: menu => &menu,

thanks
- - - - - - - - - -- - - - - -
DirectoryNautica-Italia
http://www.nauticalink.it
Quote Reply
Re: [blecchi] categories list on sub pages In reply to
In site_html_templates.pl add in the globals section at the very top:

# You can put variables here that you would like to use in any
# of your templates.
%globals = (
date => &get_date,
time => &get_time,
db_cgi_url => $db_cgi_url,
build_root_url => $build_root_url,
site_title => $build_site_title,
css => $build_css_url,
menu => &menu,
banner => ''
);


Leonard
aka PerlFlunkie