Gossamer Forum
Home : Products : Links 2.0 : Customization :

Top 10 by Hits

Quote Reply
Top 10 by Hits
Ok anyone, as there been a mod made where it shows in the top rated page..the top 10 by hits instead of votes and rating's...just want it to show the top 10 by hits nothing else..I tried myself and got it to show hits..but suffice to say it showed every link in database by order of hits instead of cutting of at top ten..anyway as anyone done this??..and AnthroRules before you say "been discussed, please search message's" I have already and found nothing that relates to it.

Admittedlamb.

Quote Reply
Re: Top 10 by Hits In reply to
Replace the sub build rate page with this:

sub build_rate_page {
# --------------------------------------------------------
# Creates a Top 10 hits page.

my (@values, $id, $hits, @top_votes, %top_votes);
local ($top_votes);

if ($build_ratings_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}

$total = 0;

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.
chomp;
@values = &split_decode ($_);
$id = $values[$db_key_pos];
$hits = $values[$db_hits];
next if ($hits < 10);
if (($#top_votes < 9) or ($hits > $top_votes[$#top_votes])) {
push (@{$top_votes{$hits}}, @values);
if ($#top_votes <= 10) {
push (@top_votes, $hits);
@top_votes = sort { $b <=> $a } @top_votes;
}
else {
splice (@{$top_votes{$#top_votes}}, 0, $#db_cols);
$#{$top_votes{$#top_votes}} or delete $top_votes{$#top_votes};
delete $top_votes{$top_votes[$#top_votes]-$id};
$top_votes[$#top_votes] = $hits;
@top_votes = sort { $b <=> $a } @top_votes;
}
}
}
close LINKS;

$top_votes = '';

foreach (sort { $b <=> $a } @top_votes) {
$seen{$_}++;
%link = &array_to_hash ($seen{$_} - 1, @{$top_votes{$_}});
$top_votes .= qq~<tr><td align=center>$link{'ID'}</td><td align=center>$link{'Hits'}</td><td><a href="$build_jump_url?ID=$link{$db_key}"
TARGET="_blank">$link{'Title'}</a></td></tr>\n~;
}

open (RATE, ">$build_ratings_path/$build_index") or &cgierr ("unable to open top rated page: $build_ratings_path/$build_index. Reason: $!");
print "\tVote Range: $top_votes[0] .. $top_votes[$#top_votes]\n";
print RATE &site_html_ratings;
close RATE;
}





And then get rid of this code in your site html templates.pl:


top_rated => $top_rated,

Then in top_rated.html delet the <%top_rated%> tag and alter the table






Good Luck!

Glenn
Host Links
http://cgi-resource.co.uk/links
Quote Reply
Re: Top 10 by Hits In reply to
Thanks Glennu...its so obivious where I made my goof when I treid to do it...then again always is when someone shows you the right way!. Thanks..now I will see if I can figure out how to do a top ten for each category.

Next person that tells me if you no javascript and or visual basic can easily do perl I will thump them one, its nothing like either..its back to front *grins*

Admittedlamb.

Quote Reply
Re: Top 10 by Hits In reply to
'now I will see if I can figure out how to do a top ten for each category.'


An easy way to do it: Just use my top rated via category mod except make a few alterations like above...

Good Luck!

Glenn
Host Links
http://cgi-resource.co.uk/links
Quote Reply
Re: Top 10 by Hits In reply to
Admittedlamb

Do you mean a single page with the top 10 of each category on it, or do you mean a separate top 10 page for each category?

Thanks.

DT

Quote Reply
Re: Top 10 by Hits In reply to
Hi Dogtags, yes I mean a seperated top 10 page for each category..that way if i wish i could call them into what ever page I wish with either a ssi or include statment.

admittedlamb.

PS: Um seperate top 10 for each top category not seperate for the subcategories underneath if ya follow me?

PSS: Glennu..um where is this top rating by each category mod?..I looked at your links page but couldn't seem to see it..but with me..well the blind leading the blind so to speak.. *cheers*

Quote Reply
Re: Top 10 by Hits In reply to
'PSS: Glennu..um where is this top rating by each category mod?..I looked at your links page but couldn't seem to see it..but with me..well the blind leading the blind so to speak.. *cheers*'


http://cgi-resource.co.uk/pages/catrate.shtml


It'll build seperate ones for sub categories as well so you'll need to alter it slightly if you just want it for top level categories.





Good Luck!

Glenn
Host Links
http://cgi-resource.co.uk/links
Quote Reply
Re: Top 10 by Hits In reply to
OK, my simple mind can't seem to grasp this..I wish to change it so it shows the top 20 instead of 10..thought it was as simple as changeing the ,<10, <=10, <9, around but doesn't seem to be so..so please fellows give me a hint ha..

Admittedlamb.

Quote Reply
Re: Top 10 by Hits In reply to
Change:

if ($#top_votes <= 10) {



To:


if ($#top_votes <= 20) {





Good Luck!

Glenn
Host Links
http://cgi-resource.co.uk/links