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

Category Menu Everywhere

(Page 2 of 2)
> >
Quote Reply
Re: [Mark2] Category Menu Everywhere In reply to
Untested (replace FieldName):

Code:

sub {
my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options ("ORDER BY FieldName DESC");
my $sth = $cat_db->select (['Full_Name'], { FatherID => 0 });
my $output;
while ( my $root_cat = $sth->fetchrow_array) {
my $url = $cat_db->as_url($root_cat);
$output .= qq~<a href="$CFG->{build_root_url}/$url">$root_cat</a><br>~;
}
return $output;
}
Quote Reply
Re: [afinlr] Category Menu Everywhere In reply to
Crashed and Burned!!! I got SQL errors all over... when I used this latest one.
$cat_db->select_options ("Sort_Order DESC");

The Sort_order is what I am sorting by (INTEGER).

Thanks..
Mark
Quote Reply
Re: [Mark2] Category Menu Everywhere In reply to
You need the ORDER BY in there

$cat_db->select_options ("ORDER BY Sort_Order DESC");
Quote Reply
Re: [afinlr] Category Menu Everywhere In reply to
Now works very nicely... thank you very much...
Mark
Quote Reply
Re: [Mark2] Category Menu Everywhere In reply to
What code and tag works with Gossamer Links 3.3.0?
http://www.hopeforyou.com

Quote Reply
Re: [HopeForYou] Category Menu Everywhere In reply to
Ok, the code above will work - or if you want more control - I've also coded a slightly different one for ya;

load_category_root
Code:
sub {
my $cat_db = $DB->table('Category');
$cat_db->select_options ("ORDER BY FieldName DESC");
my $sth = $cat_db->select (['Full_Name'], { FatherID => 0 });
my $output;
while ( my $root_cat = $sth->fetchrow_array) {
my $url = $cat_db->as_url($root_cat);
$output .= qq~<a href="$CFG->{build_root_url}/$url">$root_cat</a><br>~;
}
return \$output;
}

Code:
<%load_category_root%>

..or;

load_category_root
Code:
sub {
my $cat_db = $DB->table('Category');
$cat_db->select_options ("ORDER BY FieldName DESC");
my $sth = $cat_db->select ( { FatherID => 0 });
my @loop;
while ( my $hit = $sth->fetchrow_hashref) {
$hit->{URL} = $cat_db->as_url($hit->{Full_Name});
push @loop, $hit;;
}
return { root_cat_loop => \@loop };
}

Code:
<%load_category_root%>
<ul>
<%loop root_cat_loop%>
<li><a href="<%URL%>"><%Name%></a></li>
<%endloop%>
</ul>

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
> >