Gossamer Forum
Home : Products : Links 2.0 : Customization :

Randomizing mod, how to make new/pop stay on top

Quote Reply
Randomizing mod, how to make new/pop stay on top
I've installed the randomizing code to my db_utils.pl from this post
http://www.gossamer-threads.com/...20order%20of%20links;

everything is great except it's pretty much useless to me unless the pop&new links always stay on top and don't mix up with rest of the links every time I do a "build". I've spend around 3-4 hours working with the code and couldn't do anything.
I've read this thread http://www.gossamer-threads.com/...20order%20of%20links; and had tried every suggestion listed there atleast twice with no luck

so I've decided to make a thread here hoping that somone was successful in making it work

Here's what I have so far, the original code has been replaced in sub build_sorthit { in db_utils.pl
with this

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;
}


I also changed variable $db_sort_links in links.def file to equal 8 - $db_sort_links = 8; (don't know what it does) but people say it's needed.

Right now it randomizes all my links along with the new and pop, how do I get around that? :(

If you know how to handle this please reply I'd be VERY thankful and will help you our in anyting I can

Thanx in advance, cheers

Last edited by:

Kaz: Jul 9, 2003, 1:41 AM
Quote Reply
Re: [Kaz] Randomizing mod, how to make new/pop stay on top In reply to
in the second thread you posted look for the post by wirthit on Feb 7, 1999, 4:26 AM. In readiing what he wrote, he apparently did what you are trying to do and suceeded. But I have never used the code, so I don't know.

Notice the lines of code in his that have isnew and iscool. Notice the order - they cause the sorting by new and cool before randomizing. that same code is not in yours.



just an idea...


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Randomizing mod, how to make new/pop stay on top In reply to
nevermind, fixed everything. works like a charm.

if any of you poor souls want this code email me at peter_b@rogers.com