Gossamer Forum
Home : Products : Links 2.0 : Customization :

Help with Top X on main page (Not Top Y on Ratings)

Quote Reply
Help with Top X on main page (Not Top Y on Ratings)
I think this has been asked before, but I could not find a resolution. What I want to do is put a subset of my Top Rated Sites on my main page, e.g. Top 5 on index.htm, Top 50 on rate_top. What I've done thus far is implement the mod discussed here...

... which works fine. I then effectively duplicated the entire subroutine for just the top 5 (or whatever). The changes in my sub build_rate_page in nph_build look like this...
my (@values, $id, $votes, $rate, @top_votes, %top_votes, @top_rate, @top_incl, %top_rate, @top_incl);
$min_vote = 1;
$max_list = 5;
and after CLOSE RATE; but before the final }...
# Rate include
open (LINKS, $db_links_name) or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
LINE: while (<LINKS> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
@values = &split_decode ($_);
$id = $values[$db_key_pos];
$votes = $values[$db_votes];
$rate = $values[$db_rating];
next if ($votes < $min_vote);
if (($#top_incl < $max_list-2) or ($votes > $top_incl[$#top_incl])) {
push (@{$top_incl{$votes}}, @values);
if ($#top_incl <= $max_list-1) {
push (@top_incl, $votes);
@top_incl = sort { $b <=> $a } @top_incl;
else {
splice (@{$top_incl{$#top_incl}}, 0, $#db_cols);
$#{$top_incl{$#top_incl}} or delete $top_incl{$#top_incl};
delete $top_incl{$top_incl[$#top_incl]-$id};
$top_incl[$#top_incl] = $votes;
@top_incl = sort { $b <=> $a } @top_incl;
close LINKS;

$top_votes_incl = '';

foreach (sort { $b <=> $a } @top_incl) {
%link = &array_to_hash ($seen{$_} - 1, @{$top_incl{$_}});
$top_votes_incl .= qq~<TR><td><a href="$build_detail_url/$link{'ID'}$build_extension">$link{'Title'}</a></td><TD ALIGN="RIGHT" WIDTH=30 NOWRAP>$link{'Votes'}</TD></tr>\n~;
open (RATE_INCLUDE, ">$build_ratings_path/rate_include$build_extension") or &cgierr ("unable to open top rated page: $build_ratings_path/rate_include$build_extension. Reason: $!");
print "\tInclude Vote Range: $top_incl[0] .. $top_incl[$#top_incl]\n";
print RATE_INCLUDE &site_html_ratings_include;
Well, this doesn't pull in the links as expected... any help would be greatly appreciated!
Quote Reply
Re: Help with Top X on main page (Not Top Y on Ratings) In reply to
Solved it... problem is the variable seen.

[This message has been edited by oldmoney (edited September 28, 1999).]