Gossamer Forum
Home : Products : Links 2.0 : Customization :

Listings ordered by hits

Quote Reply
Listings ordered by hits
Does anyone know of a links modification that will order listings within categories not alphabetically but by hits. Sites with higher hits (higher pop value) are listed higher up. Besides an incentive for people to link back, it eliminates the anti-social behavior of naming sites ridiculous and inane names like AAAAWidgets in order to get one's site higher on the list.

Cheers... Dan Smile
Quote Reply
Re: Listings ordered by hits In reply to
Hi Dan,

The links code is new to me, and I haven't tried this, but I believe if you edit links.def, you will see the following line:
# Field number to sort links by:
$db_sort_links = 1;

The "1" stands for which field number you want to sort by, I believe the first field is "0". So you need to choose "8" as the sort field for hits.

However, I've seen sites that are not sorted alphabetically, and personally I don't think that it looks as good as alphabetically, except in the case of Excite or Altavista where the sort order is based on the relevancy of the query. Do you know what I mean? The links seem to have a random feel to them....



------------------
Quote Reply
Re: Listings ordered by hits In reply to
Thanks! The edit to links.def works. Problem is now I have to change the sort in db.cgi from a string to a numerical sort. String search does not work for the obvious reasons - e.g., 109 comes ahead of 11.

It's a look I prefer as the alpha sort is not really random in that many link submitters knowing this go out of their way to name their sites so that they come in at or near the top. I'd prefer to reward top hit sites - also encourages people to link back.

Now how do we convert from a string to a numerical search? I also need to reverse the sort order - right now it is an ascending order where I require a descending order.

Dan Smile
Quote Reply
Re: Listings ordered by hits In reply to
Search the archives for the "Order that links are in" thread.
Quote Reply
Re: Listings ordered by hits In reply to
I did the search but couldn't find an answer there. No source for converting from a string to numerical sort.


[This message has been edited by dan (edited December 13, 1998).]
Quote Reply
Re: Listings ordered by hits In reply to
<<<If you wanted by number of clicks and not have new/pop appear first, it's really simple, edit db.pl and
replace the sorting in build_sort_hit with:

<pre>
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_hits] + ($i * ($#db_cols+1))];
}
foreach $hit (sort { return $sortby{$a} <=> $sortby{$b} } (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
</pre>

And you should be set.

Hope that helps,

Alex >>>
Quote Reply
Re: Listings ordered by hits In reply to
Thanks! We are almost there. Now the sort is in an ascending order but I require a descending order (e.g., 100,99,98,...1).

Sorry to be such nuisance over this Smile

Dan
Quote Reply
Re: Listings ordered by hits In reply to
Hi:

I figured it out. I changed:

foreach $hit (sort { return $sortby{$a} <=> $sortby{$b} } (keys %sortby)) {

to:

foreach $hit (sort { return $sortby{$b} <=> $sortby{$a} } (keys %sortby)) {

Thanks again Smile
Quote Reply
Re: Listings ordered by hits In reply to
Hi,
Can someone please tell me how this differs for links2? I know its in db_utils.pl and the routine is now build_sorthit but I cant get it to work.. can someone please tell me exactly how the build_sorthit should look in links2? The above doesnt work.
Thanks,
David


------------------
ICQ# 12748164