Gossamer Forum
Home : Products : Links 2.0 : Installation -- Unix :

Alphabetical order

Quote Reply
Alphabetical order
Hi

Somehow my Links has lost the Alphabetical order, is there a way to reorder the Database

My site is at http://www.soaring.dk

Regards

Lars Jensen

------------------
Quote Reply
Re: Alphabetical order In reply to
If you want your links to be alphabetized (rather than sorted by new and cool), then replace your sub build_sorthits with the following codes:

Code:
sub build_sorthits {
# 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, $hit, $i, @sorted);
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
}
foreach $hit (sort {
return lc($sortby{$a}) cmp lc($sortby{$b});
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;

}

BTW: This question would be better suited in the Modification Forum since it deals with code hacking.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




Quote Reply
Re: Alphabetical order In reply to
We started here

I got an error when i tried the script modification, is there an error in the script ?

Lars

------------------
Quote Reply
Re: Alphabetical order In reply to
Well, it works for me! I COPIED the EXACT codes that I am using for alphabetical order.

Rather than saying "I got errors.", how about being more specific and providing the EXACT error messages you are receiving. Look at your Perl Error Log, Check the syntax of the file via telnet, or turn on the db_debug variable on with 1 in the links.cfg file.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




Quote Reply
Re: Alphabetical order In reply to
CGI ERROR
==========================================
Error Message : fatal error: Undefined subroutine &main::build_sorthit called at nph-build.cgi line 641.

Script Location : nph-build.cgi
Perl Version : 5.00404

Form Variables
-------------------------------------------

Environment Variables
-------------------------------------------
HISTFILESIZE : 0
HISTSIZE : 1000
HOME : /home/sites/site11/users/soaring
HOSTNAME : www.zip2net.dk
HOSTTYPE : mips
LOGNAME : soaring
MAIL : /var/spool/mail/soaring
OSTYPE : Linux
PATH : /usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
PS1 : [\u \W]\$
SHELL : /bin/bash
SHLVL : 1
TERM : vt100
USER : soaring
_ : /usr/bin/perl
Quote Reply
Re: Alphabetical order In reply to
Got it:
sub build_sorthits was
sub build_sorthit

???

Its working thankyou !
Quote Reply
Re: Alphabetical order In reply to
GOOD! Finally!

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
http://www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------