Gossamer Forum
Quote Reply
hey Laura
I'm using one of your globals posted long time ago, one thing i need help in is how come it won't work when i change the sort order. i changed to ORDER BY Title or anything else but dun work!?

sub {
my $tags = shift;
my $cat_id = $tags->{'ID'};
my $name = $tags->{'Name'};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options ("ORDER BY $CFG->{build_sort_order_category}");
my $sth = $link_db->select ( { CategoryID => $cat_id, isValidated => 'Yes' });

my $output = qq~ <b>$name:</b><br> ~;

while (my $link = $sth->fetchrow_hashref) {
$output .= qq~ <li>$link->{'Title'} ~;
}

my $cat_db = $DB->table('Category');
my $sth2 = $cat_db->select ( ['ID','Name'],{ FatherID => $cat_id });

while (my ($child_id,$subname) = $sth2->fetchrow_array){
$output .= qq~ <br><br><b>$subname:</b><br> ~;

my $sth3 = $link_db->select ( { CategoryID => $child_id, isValidated => 'Yes' });

while (my $link2 = $sth3->fetchrow_hashref) {
$output .= qq~ <li>$link2->{'Title'} ~;
}
}

return $output;
}
Quote Reply
Re: [xpert] hey Laura In reply to
Don't forget its referencing both CatLinks and Links table, so both of these may not have the same fields. I'm not sure if this could be why a custom ORDER BY thing would cause an error though Unimpressed

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: [xpert] hey Laura In reply to
I'm not sure what you mean by it doesn't work - is it giving an error message or just not sorting?

If its just not sorting, try $link_db->select_options ("ORDER BY Title ASC");

Laura.
The UK High Street
Quote Reply
Re: [afinlr] hey Laura In reply to
It just don't sort!
Quote Reply
Re: [xpert] hey Laura In reply to
Even using the line above?
Quote Reply
Re: [afinlr] hey Laura In reply to
yeah, even using the line above!
Quote Reply
Re: [xpert] hey Laura In reply to
Well I've just copied the global you're using and added $link_db->select_options ("ORDER BY Title ASC"); instead of the one that's there and it sorts the lists alphabetically by title.

Could it be that your page is cached and is not refreshing properly?

Laura.
The UK High Street
Quote Reply
Re: [xpert] hey Laura In reply to
Sorry - wasn't paying enough attention. The main category list was sorted alphabetically but not the sub categories. Try this:

sub {
my $tags = shift;
my $cat_id = $tags->{'ID'};
my $name = $tags->{'Name'};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options ("ORDER BY Title ASC");
my $sth = $link_db->select ( { CategoryID => $cat_id, isValidated => 'Yes' });

my $output = qq~ <b>$name:</b><br> ~;

while (my $link = $sth->fetchrow_hashref) {
$output .= qq~ <li>$link->{'Title'} ~;
}

my $cat_db = $DB->table('Category');
my $sth2 = $cat_db->select ( ['ID','Name'],{ FatherID => $cat_id });

while (my ($child_id,$subname) = $sth2->fetchrow_array){
$output .= qq~ <br><br><b>$subname:</b><br> ~;
$link_db->select_options ("ORDER BY Title ASC");
my $sth3 = $link_db->select ( { CategoryID => $child_id, isValidated => 'Yes' });

while (my $link2 = $sth3->fetchrow_hashref) {
$output .= qq~ <li>$link2->{'Title'} ~;
}
}

return $output;
}
Quote Reply
Re: [afinlr] hey Laura In reply to
Cool, thx everthing working fine now!