Gossamer Forum
Quote Reply
Links Custom Sort
Is there a way to create custom sorted list of links which are not sorted by build_sort_order_category variable?

For Example:

Links have following parameters : City_Name, County_Name, Language


I want to create 3 link lists in one category page one arranged by City_Name other by County_Name and another by Language:


List 1


City_Name1 Link1
City_Name1 Link2
City_Name2 Link3
City_Name2 Link4
City_Name2 Link5


List 2


County_Name1 Link5
County_Name1 Link2
County_Name2 Link3
County_Name2 Link4
County_Name2 Link9


List 3


Language1 Link7
Language1 Link8
Language1 Link2
Language2 Link4
Language2 Link1




Thank you in advance!


Quote Reply
Re: [AMIXIMA] Links Custom Sort In reply to
Hi,

Are you wanting to load those just in specific categories, or results from the WHOLE database (but just showing in specific categories) ?

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
Quote Reply
Re: [Andy] Links Custom Sort In reply to
Hi Andy,

I would like to have this link lists on selected categories.
Quote Reply
Re: [AMIXIMA] Links Custom Sort In reply to
Hi,

Took a little while to do, but here you go:

load_links
Code:
sub {

my ($limit,$sort_order,$cat_id) = (shift,shift,shift);
my @queries = @_;

$sort_order ||= "Title ASC";

my $tbl = $DB->table('Links');

if ($limit) {
$tbl->select_options(qq|ORDER BY $sort_order LIMIT $limit|);
} else {
$tbl->select_options(qq|ORDER BY $sort_order|);
}

my $cond = new GT::SQL::Condition;

foreach (@queries) {
my ($field,$operator,$val) = split /::/;
$cond->add($field,$operator,$val);
}
$cond->bool("AND");

my $sth = $tbl->select( $cond, { 'CatLinks.CategoryID' => $cat_id } ) || die $GT::SQL::error;

my @loop;
while (my $hit = $sth->fetchrow_hashref) {

$hit = Links::SiteHTML::tags('link', $hit);
push @loop, $hit;
}

return { cond_loop_link => \@loop }


}


Call with:

Code:
<%load_links(LIMIT,'SORT ORDER',CATEGORY_ID,'isValidated::=::Yes','Foo::LIKE::%bar%')%>

...so a "proper" example:

Code:
<%load_links(10,'Title ASC',123,'isValidated::=::Yes','Foo::LIKE::%bar%')%>

..which would get links from category ID 123, sorted by Title ASC and limit it to 10. It would also look for:

Code:
isValidated => Yes
Foo LIKE "%bar%"

If you are calling this from inside a category that you wanna get the results from, you can use $category_id in the place of 123.

To show the results you just do:

Code:
<%loop cond_loop_link%>
<%include link.html%>
<%endloop%>

Hope that helps.

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
Quote Reply
Re: [Andy] Links Custom Sort In reply to
Hi Andy,

thank you very much for the code!

Could you please explain a bit more about part?

isValidated => Yes
Foo LIKE "%bar%"




Thanks again.
Quote Reply
Re: [AMIXIMA] Links Custom Sort In reply to
You would just run it like this from category.html (for your example);

Code:
<%load_links(25,'City_Name ASC',$category_id,'isValidated::=::Yes')%>
<h2>Listings sorted by City name:</h2>
<%loop cond_loop_link%>
<%include link.html%>
<%endloop%>

<%load_links(25,'County_Name ASC',$category_id,'isValidated::=::Yes')%>
<h2>Listings sorted by County name:</h2>
<%loop cond_loop_link%>
<%include link.html%>
<%endloop%>

<%load_links(25,'Language ASC',$category_id,'isValidated::=::Yes')%>
<h2>Listings sorted by Language :</h2>
<%loop cond_loop_link%>
<%include link.html%>
<%endloop%>

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
Quote Reply
Re: [Andy] Links Custom Sort In reply to
Andy,

Thank you again for your help!!!