Gossamer Forum
Home : Products : Links 2.0 : Customization :

Re: Links as Voting Topsites?

Quote Reply
Re: Links as Voting Topsites? In reply to
Hi

I have installed this mod, but it doesn't seem to generate a top five in each category. The tag is recognised in the template and I don't get any errors.

I have followed widgetz instructions carefully.

This is the appropriate section of my nph_build

sub build_top_x {
my ($category) = @_;
my (@values, $top_cat, @topx, $topxhtml, $count);
$original = $db_sort_links;
$db_sort_links = $db_rating;
@topx = &build_sorthit (@{$links{$category}});
$db_sort_links = $original;
$topxhtml = qq~<table cellpadding="0" cellspacing="0" border="0">\n~;
my $display = 5;
(($#topx+1) / ($#db_cols+1) >= $display) or $display = ($#topx+1)/($#db_cols+1);
for ($i = 0; $i < $display; $i++) {
%tmp = &array_to_hash ($i, @topx);
$count = $i+1;
$topxhtml .= qq~<tr><td valign="top"><$font><b>$count.</b></font> </td><td valign="top"><$font>~;
if ($tmp{'isDetailed'} eq "Yes") { $topxhtml .= qq~<a href="$build_detail_url/$tmp{$db_key}$build_extension"><b>$tmp{'Title'}</b></a>~; }
else { $topxhtml .= qq~<a href="$build_jump_url?$db_key=$tmp{$db_key}"><b>$tmp{'Title'}</b></a>~; }
$topxhtml .= qq~</font><br><$font_small>($tmp{'Hits'} Downloads)</font></td></tr>\n~;
}
$topxhtml .= qq~</table>~;
return $topxhtml;
}

my dbutils file has the following section in it

sub build_sorthit {
# --------------------------------------------------------
# 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, %isnew, %iscool, $hit, $i, @sorted, $column, $type);

foreach $column (@db_cols) {
if ($db_sort_links == $db_def{$column}[0]) {
$type = $db_def{$column}[1];
last;
}
}
for ($i = 0; $i < $num; $i++) {
$sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
($unsorted[$db_isnew + ($i * ($#db_cols+1))] eq "Yes") and ($isnew{$i} = 1);
($unsorted[$db_ratings + ($i * ($#db_cols+1))] eq "Yes") and ($iscool{$i} = 1);
}
if ($type eq "date") {
foreach $hit (sort {

&date_to_unix ($sortby{$b}) <=> &date_to_unix ($sortby{$a});
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
}
elsif ($type eq "numer") {
foreach $hit (sort {
$sortby{$b} <=> $sortby{$a};
} (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit;
$last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sorted, @unsorted[$first .. $last]);
}
}
else {
foreach $hit (sort {
($isnew{$b} and !$isnew{$a}) and return 1;
($isnew{$a} and !$isnew{$b}) and return -1;
($iscool{$b} and !$iscool{$a}) and return 1;
($iscool{$a} and !$iscool{$b}) and return -1;
($isnew{$a} and $isnew{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
($iscool{$a} and $iscool{$b}) and return lc($sortby{$a}) cmp lc($sortby{$b});
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;
}

sub urlencode {
# --------------------------------------------------------
# Escapes a string to make it suitable for printing as a URL.
#
my($toencode) = shift;
$toencode =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$toencode =~ s/\%2F/\//g;
return $toencode;
}

Also I am using widgetz review mod.

I currently don't have that many reviews, is there a minimum number required hidden somewhere in this code?


Any ideas what I am missing?

Thanks

Rob





Subject Author Views Date
Thread Links as Voting Topsites? Karl 7517 Oct 16, 1999, 7:45 PM
Post Re: Links as Voting Topsites?
widgetz 6974 Oct 16, 1999, 7:49 PM
Post Re: Links as Voting Topsites?
Karl 6994 Oct 16, 1999, 7:54 PM
Post Re: Links as Voting Topsites?
widgetz 6932 Oct 16, 1999, 8:56 PM
Post Re: Links as Voting Topsites?
Karl 7016 Oct 17, 1999, 3:58 AM
Post Re: Links as Voting Topsites?
Eliot 6987 Oct 17, 1999, 12:21 PM
Post Re: Links as Voting Topsites?
widgetz 6939 Oct 17, 1999, 12:35 PM
Post Re: Links as Voting Topsites?
Eliot 7019 Oct 17, 1999, 1:14 PM
Post Re: Links as Voting Topsites?
widgetz 6989 Oct 17, 1999, 1:33 PM
Post Re: Links as Voting Topsites?
ron4315 6994 Oct 17, 1999, 4:50 PM
Post Re: Links as Voting Topsites?
Eliot 6949 Oct 17, 1999, 5:07 PM
Thread Re: Links as Voting Topsites?
widgetz 7043 Oct 17, 1999, 5:08 PM
Post Re: Links as Voting Topsites?
wirefram 2944 Dec 11, 2000, 11:59 AM
Post Re: Links as Voting Topsites?
widgetz 6940 Oct 17, 1999, 5:09 PM
Post Re: Links as Voting Topsites?
widgetz 6960 Oct 17, 1999, 5:12 PM
Post Re: Links as Voting Topsites?
Eliot 6975 Oct 17, 1999, 5:19 PM
Post Re: Links as Voting Topsites?
ron4315 6982 Oct 17, 1999, 5:20 PM
Post Re: Links as Voting Topsites?
widgetz 6942 Oct 17, 1999, 5:24 PM
Post Re: Links as Voting Topsites?
widgetz 6982 Oct 17, 1999, 5:28 PM
Post Re: Links as Voting Topsites?
ron4315 7001 Oct 17, 1999, 5:29 PM
Post Re: Links as Voting Topsites?
widgetz 6999 Oct 17, 1999, 5:41 PM
Post Re: Links as Voting Topsites?
Eliot 6946 Oct 17, 1999, 5:51 PM
Post Re: Links as Voting Topsites?
Karl 6924 Oct 17, 1999, 8:31 PM
Post Re: Links as Voting Topsites?
Eliot 6986 Oct 18, 1999, 5:26 AM
Post Re: Links as Voting Topsites?
ron4315 6993 Oct 18, 1999, 12:24 PM
Post Re: Links as Voting Topsites?
ron4315 6982 Oct 18, 1999, 12:34 PM
Post Re: Links as Voting Topsites?
Eliot 7717 Oct 18, 1999, 3:23 PM
Post Re: Links as Voting Topsites?
Brad Richardson 7599 Oct 20, 1999, 6:53 AM
Post Re: Links as Voting Topsites?
Karl 7583 Oct 20, 1999, 7:30 AM
Post Re: Links as Voting Topsites?
socrates 7623 Oct 20, 1999, 5:05 PM
Post Re: Links as Voting Topsites?
widgetz 7588 Oct 20, 1999, 6:19 PM
Post Re: Links as Voting Topsites?
socrates 7658 Oct 21, 1999, 1:15 PM
Post Re: Links as Voting Topsites?
widgetz 7612 Oct 21, 1999, 3:51 PM
Post Re: Links as Voting Topsites?
ron4315 7628 Oct 21, 1999, 4:56 PM
Post Re: Links as Voting Topsites?
widgetz 7625 Oct 21, 1999, 5:09 PM
Post Re: Links as Voting Topsites?
socrates 7607 Oct 21, 1999, 5:47 PM
Post Re: Links as Voting Topsites?
widgetz 7595 Oct 21, 1999, 6:27 PM
Post Re: Links as Voting Topsites?
joloo 7607 Nov 9, 1999, 1:52 PM
Post Re: Links as Voting Topsites?
Eliot 7604 Nov 9, 1999, 1:57 PM
Post Re: Links as Voting Topsites?
joloo 7608 Nov 9, 1999, 4:41 PM
Post Re: Links as Voting Topsites?
Eliot 7615 Nov 9, 1999, 4:45 PM
Post Re: Links as Voting Topsites?
joloo 7613 Nov 10, 1999, 10:44 AM
Post Re: Links as Voting Topsites?
Eliot 7538 Nov 10, 1999, 5:58 PM
Post Re: Links as Voting Topsites?
joloo 7566 Nov 11, 1999, 1:58 AM
Post Re: Links as Voting Topsites?
Bmxer 7559 Nov 11, 1999, 2:27 AM
Post Re: Links as Voting Topsites?
joloo 7519 Nov 11, 1999, 3:08 PM
Post Re: Links as Voting Topsites?
Eliot 7567 Nov 11, 1999, 3:14 PM
Post Re: Links as Voting Topsites?
widgetz 7573 Nov 11, 1999, 6:15 PM
Post Re: Links as Voting Topsites?
joloo 7532 Nov 14, 1999, 12:17 PM
Post Re: Links as Voting Topsites?
Bmxer 7523 Nov 14, 1999, 12:35 PM
Post Re: Links as Voting Topsites?
joloo 7636 Nov 16, 1999, 12:47 PM
Post Re: Links as Voting Topsites?
jooloo 3372 Jan 31, 2000, 1:28 PM
Post Re: Links as Voting Topsites?
RobL 3326 May 1, 2000, 2:39 AM
Post Re: Links as Voting Topsites?
Stealth 3381 May 1, 2000, 2:41 PM
Post Re: Links as Voting Topsites?
rdm 3341 May 2, 2000, 4:01 PM
Post Re: Links as Voting Topsites?
Stealth 3337 May 2, 2000, 4:04 PM
Post Re: Links as Voting Topsites?
rdm 3376 May 2, 2000, 4:16 PM
Post Re: Links as Voting Topsites?
Stealth 3310 May 2, 2000, 4:47 PM
Post Re: Links as Voting Topsites?
doms 3128 Aug 22, 2000, 11:11 AM