Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Global to catch category list

Quote Reply
Global to catch category list
This global should catch top level categories and display it accross all site.

Code:
sub {
my $tags = shift;
my $cat_db = $DB->table('Category');
my @root_cats = $cat_db->select (['Full_Name'], { FatherID => 0 })->fetchall_list;
my $output;
foreach my $root_cat (@root_cats) {
my $url = $cat_db->as_url($root_cat);
$output .= qq~<li class="detail"><a href="$url">$root_cat</a></li>~;
}
return $output;
}

However, it doesn't work good. When I'm in root, it's ok. But when I go in some subdirectory, URL to displayed TOP LEVEL categories isn't right.

I like PHP but dislike PERL so don't know how to fix it Wink

Regards.

UnReal Network
Quote Reply
Re: [DeadMan] Global to catch category list In reply to
Got an example? I can't see why it would work any different on main pages, and sub-categories.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Global to catch category list In reply to
This is URL on main page to some category: http://www.domain.com/directory/107/, and this is link on detailed page: http://www.domain.com/directory/Detailed/category_of_link_which_we_look_in_detail_mode/107

Regards.

UnReal Network
Quote Reply
Re: [DeadMan] Global to catch category list In reply to
Try changing:

my $url = $cat_db->as_url($root_cat);

...to:

my $url = "/directory/" . $cat_db->as_url($root_cat);

That should sort it :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Global to catch category list In reply to
It's aaaaliiiiive! Smile

Thanks.

Regards.

UnReal Network
Quote Reply
Re: [DeadMan] Global to catch category list In reply to
hahah np

What may actually be better (not so much for you, but if anyone else is having this same issue), is to actually use:

Code:
my $url = $CFG->{build_root_url} . "/" . $cat_db->as_url($root_cat);

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Global to catch category list In reply to
One more question.

Categories are now sorted by ID and I want to sort it by Name. How to do that?

Regards.

UnReal Network
Quote Reply
Re: [DeadMan] Global to catch category list In reply to
After:

my $cat_db = $DB->table('Category');

Add:

$cat_db->select_options("ORDER BY Name");

That should work

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!