Gossamer Forum
Home : Products : Links 2.0 : Customization :

Problem with sorting links by date

Quote Reply
Problem with sorting links by date
Hi,

I am sorting the links by date but I am having a problem since 10/02. It put the last links I added (since 10-Jan-2001) to the end of the list but it also keep on sorting the other ones in the right form. Can someone tell me what I should do to fix it?
I use links2.0 for a news service that's whay I must sort them by date. You can see the main page of the news page at http://runto.roxette.org/News/Noticias/ and the last article that I added at the end of this page: http://runto.roxette.org/News/Noticias/more3.html (that should be at the main page).
Bye bye and thanks in advanced for any help you can give me...

Jorge

Quote Reply
Re: Problem with sorting links by date In reply to
What modifications have you added to your LINKS script?

Regards,

Eliot Lee
Quote Reply
Re: Problem with sorting links by date In reply to
I added: review.cgi, tell2.cgi, info.cgi and I think that nothing more. I put the link to sort by date and all was working great but I am having this problem and don't know how fix it. Can you please help me?
Good bye and thanks...

Jorge

Quote Reply
Re: Problem with sorting links by date In reply to
Well then, the problem is that you have replaced the sub build_sorthit routine, which no longer sorts by date for your links.

So, what you need to do is use another sub called something like sub build_other_sorthit for the TELL2 and REVIEW mods, and then use the standard sub build_sorthit routine for sorting links in the category and search result pages.

Got it?

Regards,

Eliot Lee
Quote Reply
Re: Problem with sorting links by date In reply to
Hello,

I didn't made any modification over there since I instaled all so I think it should be working. I am not sure what you want to mean but here is what I have there:

sub build_sorthit {
# --------------------------------------------------------
# This function sorts a list of links. It has been modified to sort
# new links first, then cool links, then the rest alphabetically. By modifying
# the sort function below, you can sort the links however you like (by date,
# or random, etc.).
#
my (@unsorted) = @_;
my ($num) = ($#unsorted+1) / ($#db_cols+1);
my (%sortby, %isnew, %iscool, $hit, $i, @sorted);

for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
($unsorted[$db_isnew + ($i * ($#db_cols+1))] eq "Yes") and ($isnew{$i} = 1);
($unsorted[$db_ispop + ($i * ($#db_cols+1))] eq "Yes") and ($iscool{$i} = 1);
}
foreach $hit (sort {
($isnew{$b} and !$isnew{$a}) and return 1;
($isnew{$a} and !$isnew{$b}) and return -1;
($iscool{$b} and !$iscool{$a}) and return 1;
($iscool{$a} and !$iscool{$b}) and return -1;
($isnew{$a} and $isnew{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
($iscool{$a} and $iscool{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
return lc($sortby{$b}) cmp lc($sortby{$a});
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}

I think it's ok, no? or what I should?
Good bye and thank you so much for your help...

Jorge

Quote Reply
Re: Problem with sorting links by date In reply to
No...You have changed the value for the $db_sort_link variable in the links.def file, right? If not, then your reviews and comments are probably not working correctly either!

Regards,

Eliot Lee
Quote Reply
Re: Problem with sorting links by date In reply to
Yes I changed it, I have now:

# Field number to sort links by:
$db_sort_links = 3;

But what I should change?

Quote Reply
Re: Problem with sorting links by date In reply to
Is so strange because If I add to it the date "9-Jan-2001" or another day before that date it sort it ok without problems. But if I add "10-Jan-2001", "11-Jan-2001" or another day before it put that link to the last.
Do you know what could be?