Gossamer Forum
Home : Products : Links 2.0 : Customization :

Links as Voting Topsites?

(Page 1 of 3)
> >
Quote Reply
Links as Voting Topsites?
Hi,

whats about making Links a Voting-Topsites with categorys?

External rating and a Top 10 for every category should do the job :-)

Has someone done this already?

Karl
Quote Reply
Re: Links as Voting Topsites? In reply to
it's really easy to do.. i already made a mod to do top X for each category..

jerry

[This message has been edited by widgetz (edited October 16, 1999).]
Quote Reply
Re: Links as Voting Topsites? In reply to
Hi widgetz,

can i take a look at it?

Karl
Quote Reply
Re: Links as Voting Topsites? In reply to
Code:
sub build_top_x {
my ($category) = @_;
my (@values, $top_cat, @topx, $topxhtml, $count);

open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
$top_cat = $values[$db_category];
next unless ($top_cat =~ /^$category/);
push (@topx, @values);
}

$db_sort_links = "14";
@topx = &build_sorthit (@topx);
$db_sort_links = "1";
close DB;

$topxhtml = qq~<table cellpadding="0" cellspacing="0" border="0">\n~;
my $display = 5;
(($#topx+1) / ($#db_cols+1) >= 5) 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;
}

you'd do something like

$top = &build_top_x ($cat);

in the category subroutine..

you will need the build_sorthit used with review.cgi 1...
http://www.widgetz.com/review/?1

keep pressing next until you make it to db_utils.pl

jerry

[This message has been edited by widgetz (edited October 17, 1999).]
Quote Reply
Re: Links as Voting Topsites? In reply to
Hi widgetz,

thanks a lot for your help!

Karl

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

Great Mod...however, when I added it, I got an Out of Memory Error.

(Yes, I am building my index via telnet.)

Wink

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited October 17, 1999).]
Quote Reply
Re: Links as Voting Topsites? In reply to
oh.. yea.. i just remember that it loads the links.db every single category Wink

there is a better way however.. to not load it..

stupid me Wink

Code:
sub build_top_x {
my ($category) = @_;
my (@values, $top_cat, @topx, $topxhtml, $count);
$db_sort_links = "14";
@topx = &build_sorthit (@{$links{$category}});
$db_sort_links = "1";

$topxhtml = qq~<table cellpadding="0" cellspacing="0" border="0">\n~;
my $display = 5;
(($#topx+1) / ($#db_cols+1) >= 5) 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;
}

i forgot to tell you

the first:
Code:
$db_sort_links = "14";

change the number to the field number of Hits

and then

the second one to the original one you have in links.def

jerry
Quote Reply
Re: Links as Voting Topsites? In reply to
Jerry,

Hi...okay, I understand the number of the first variable, but I don't understand:

Code:
top => $top,

Then in your category.html file, add the following tag in the spot where want these top sites to appear:

Code:
<%top%>

I also changed the jump.cgi codes to $tmp{'URL'} to avoid the problems that arise with people clicking on links many times to increase their hits and subsequently have their sites stay in the Top Sites area.

Thanks again, Jerry!

Smile

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited October 17, 1999).]

[This message has been edited by Eliot (edited October 17, 1999).]
Quote Reply
Re: Links as Voting Topsites? In reply to
go to links.def and you will see it.. Wink

it's because you have to switch it back to the original one in order for it to sort the other pages right.. you could do this

Code:
$original = $db_sort_links;
$db_sort_links = $db_def{'Hits'}[0];
@topx = &build_sorthit (@{$links{$category}});
$db_sort_links = $original;

and then you won't need to edit anything..

jerry
Quote Reply
Re: Links as Voting Topsites? In reply to
Hmmm,

I dont quite follow all these variations in installing such a Mod.

Ok Eliot you said for template users, put the top => $top; into the template_html.pl

I did that and used the <%top%> and got no change when I built the pages.

I used Widgetz db_utils.db modification, and added the code he posted into my nph-build.cgi.

Is there anything I am missing?
Thanks Smile
------------------
BeatBox Entertainment
beat-box.com
Ron Newbigging



[This message has been edited by ron4315 (edited October 17, 1999).]
Quote Reply
Re: Links as Voting Topsites? In reply to
Sorry if you are confused, but there are no variations of the Mod. The Mod was written by Jerry.

Wink

Here is what you need to do for templates:

1) Add the following sub-routine in your nph-build.cgi file. This can be placed at the end of the script:

Code:
sub build_top_x {
my ($category) = @_;
my (@values, $top_cat, @topx, $topxhtml, $count);
$db_sort_links = "14";
@topx = &build_sorthit (@{$links{$category}});
$db_sort_links = "1";
$topxhtml = qq~<table cellpadding="0" cellspacing="0" border="0">\n~;
my $display = 5;
(($#topx+1) / ($#db_cols+1) >= 5) 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;
}

2) Then add the following codes:

Code:
$top = &build_top_x ($cat);

AFTER the following codes in the sub build_category_pages routine in the nph-build.cgi file:

Code:
$title_linked = &build_linked_title ($cat);
$title = &build_unlinked_title ($cat);
$total = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
$category_name = $cat;
$category_name_escaped = &urlencode ($cat);
$category_clean = &build_clean ($cat);

3) Add the following codes:

Code:
$t1 = time();
print "** Creating Top Sites in Categories. . .\n";
&build_top_x;
print "** Done (", time - $t1, " s)!\n\n";

AFTER the following codes:

Code:
$t1 = time();
print "** Creating What's Cool Page. . .\n";
&build_rate_page;
print "** Done (", time - $t1, " s)!\n\n";

in the sub build_staggered routine in the nph-build.cgi file.

4) Add the following codes:

Code:
# Create Top Sites in Categories
print "Building Top Sites in Categories . . .\n";
&build_top_x;
print "Done\n\n";

AFTER the following codes in the sub build_all routine in nph-build.cgi:

Code:
# Create What's Cool Page
$use_html ?
print "Building <A HREF=\"$build_ratings_url/$build_index\">What's Cool</A> Page . . .\n" :
print "Building Top Rated . . .\n";
&build_rate_page;
print "Done\n\n";

5) Add the following codes to the sub site_html_category routine in the %load_template area:

Code:
top => $top,

6) Then in your category.html template file, add the following tag to the spot in the page where you want the Top Sites located:

Code:
<%top%>

Hope this makes it clear.

Smile

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited October 17, 1999).]
Quote Reply
Re: Links as Voting Topsites? In reply to
ok.. for templates..

add this subroutine to the end of nph-build.cgi

Code:
sub build_top_x {
my ($category) = @_;
my (@values, $top_cat, @topx, $topxhtml, $count);
$original = $db_sort_links;
$db_sort_links = $db_hits;
@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;
}

then in build_category_pages (in nph-build.cgi)

below:

Code:
$category_clean = &build_clean ($cat);

add:

Code:
$topx = &build_top_x ($cat);

then in site_html_category (in site_html_templates.pl)

add this to the list of variables.. anywhere in it..

Code:
topx => $topx,

then in the html page add <%top%> and it should show up..

jerry

[This message has been edited by widgetz (edited October 17, 1999).]
Quote Reply
Re: Links as Voting Topsites? In reply to
aww.. eliot beat me Wink

jerry
Quote Reply
Re: Links as Voting Topsites? In reply to
eliot.. where did step 3 and 4 come in?

btw.. you should use the subroutine i posted in my instructions.. it automates the process of getting the IDs.. i just made that change a second ago..

jerry
Quote Reply
Re: Links as Voting Topsites? In reply to
All I did was add the steps of adding checks in the build all and build staggered process.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Links as Voting Topsites? In reply to
Wouldnt it be <%top%> instead of <%topx%> Widgetz?

------------------
BeatBox Entertainment
beat-box.com
Ron Newbigging



[This message has been edited by ron4315 (edited October 17, 1999).]
Quote Reply
Re: Links as Voting Topsites? In reply to
no.. i changed it to topx cause i think top is too common..

jerry
Quote Reply
Re: Links as Voting Topsites? In reply to
eliot..

http://www.gossamer-threads.com/...um3/HTML/003405.html

(just something i thought you could use.. after going to your site.. i beleive you are doing those yahoo style links by hand? [the new one does it in the order you want it to be in..] i just wanted you to try it)

also.. why did you need step 3 and 4.. they don't do anything.. it just goes through the subroutine and returns nothing..

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

One more thing, It worked thanks!

But I got a lot of empty brackets, " <> " and also, it doesnt seem to be ranking on anything in particular?!

How would I be able to make it rank on Rating?

------------------
BeatBox Entertainment
beat-box.com
Ron Newbigging

Quote Reply
Re: Links as Voting Topsites? In reply to
ok.. now i'm such a retard..

i changed:

Code:
$db_sort_links = $db_def{$db_cols[$db_hits]}[0];

to

Code:
$db_sort_links = $db_hits;

just change $db_hits to $db_rating or whatever yours is..

jerry
Quote Reply
Re: Links as Voting Topsites? In reply to
ron4315,

You also need to change <$font> in the codes that Jerry wrote. This variable is defined in the non-templates version. But with templates, the font style does not show. You need to manually add in the font anchors.

Smile

Jerry,

The only reason I put Step 3 and 4 was so that I can check to see if that process has been completed. Also, I am not using Yahoo's bolded tags. But I will give that Mod a shot.

Wink

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Links as Voting Topsites? In reply to
Hi widgetz,

i use your mod and everything works fine, but the "ranking" is in wrong order.
There is no System in it, like the one with the most hits on top.

Also most of the entrys in the category are not shown.

As example:

1. Some Link (9 Hits)
2. Some Link (320 Hits)
3. Some Link (1 Hits)
4. Some Link (1 Hits)
5. Some Link (1 Hits)

But there are also entrys with 123 or 212 Hits, but there are not in the toplist.

Do you have an solution?

Karl


[This message has been edited by Karl (edited October 18, 1999).]
Quote Reply
Re: Links as Voting Topsites? In reply to
Yea...In Jerry's earlier post, he mentioned that you need to edit the sub build_sorthit routine in the db_utils.pl file.

Go to the following URL for information on what you need to edit the sub build sorthit routine:

http://www.widgetz.com/...w/instructions.cgi?4

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Links as Voting Topsites? In reply to
Hi,

I dont understand what you meant by replacing that line with "$db_sort_links = $db_hits;" ?

What script is that line suppose to be in? This will fix the sorting routine right to rate from most hits to leasT?

------------------
BeatBox Entertainment
beat-box.com
Ron Newbigging

Quote Reply
Re: Links as Voting Topsites? In reply to
Oops,
One more thing...

How can this be incorporated in utilizing the link.html template as well?



------------------
BeatBox Entertainment
beat-box.com
Ron Newbigging

> >