Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Random links and new/pop at the top.

Quote Reply
Random links and new/pop at the top.
Hi

I've installed this script to have random links appear everytime I do build:

Start
------------------------
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))];
if ($unsorted[$db_isnew + ($i * ($#db_cols+1))] eq "Yes") { $isnew{$i} = 1; }
if ($unsorted[$db_ispop + ($i * ($#db_cols+1))] eq "Yes") { $iscool{$i} = 1; }
}
srand;
foreach $hit (sort { return int(rand(1) + 0.5) ? 1 : -1 } (keys %sortby)) {

$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
return @sorted;
}
----------------------
END!


I've heard that by default it should put pop/new links to the top of the page, and after all ther other random links.
I set isPopular to Yes for the link I need to be at the top, then press build but I still have ALL links put in there randomly.

What am I doing wrong?

Thanks,
Art.
Subject Author Views Date
Thread Random links and new/pop at the top. dij 1874 Jun 27, 2003, 12:27 AM
Post Re: [dij] Random links and new/pop at the top.
dij 1788 Jul 4, 2003, 10:33 PM