Gossamer Forum
Home : Products : Links 2.0 : Customization :

How can I put only the top 10 sites (by votes) on the homepage?

(Page 1 of 2)
> >
Quote Reply
How can I put only the top 10 sites (by votes) on the homepage?
Hi!

How can I put and FORMAT only the top 10 sites (by votes) on the homepage?

I mean: on the main page, put inside a table a column that reads:

Top on Xxxxx
------------
1. Xxxxxxxxx (323 votes)
2. Xxxxxxx (233 votes)
3. Xxxxxxxx (33 votes)

and so, up to 10.

Thanks!


------------------
Alex Tutusaus
Atyc WebDesigns
http://www.webcamworld.com/
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Go to sub build_rate_page where it says
Code:
open (RATE, ">$build_ratings_path/$build_index") or.....
and copy down to
Code:
close RATE; }

Just duplicate that but change $build_index to something like $build_index_include.

And change &site_html_ratings to something like &site_html_ratings_include.

Then you'll have to go to site_html.pl or site_html_templates.pl and copy the sub site_html_ratings and create your sub site_html_ratings_include that you referenced above.

There you can change the template rate_top.html to rate_top_include.html, make your template file for rate_top_include.html and build pages.

From there you can decide to either pull the extra page in via ssi or have it built on the home page template using a <%tag%>.

I haven't done this yet. But I'm sure it will work. If you want to change the way the links look you'll have to create a link_include.html template too and reference that.
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Hi!

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


Created:

Code:

sub site_html_ratings_incl {
# --------------------------------------------------------
# This routine determines how the top rated page will look like.

return &load_template ( 'rate_top_incl.html', {
top_rated => $top_rated,
top_votes => $top_votes,
%globals
});
}

And created template rate_top_incl:
Code:
<font face="Arial,Helvetica">
<%top_rated%>
</font>

When building,
The error I get is:

Code:
CGI ERROR
==========================================
Error Message : unable to open top rated page: //home/camcities.com/www/Ratings/. Reason: Is a directory
Script Location : nph-build.cgi
Perl Version : 5.00503

So what does Ratings dir have to do with this?

How do I include the template on the home template later?

YOu mentioned something to format the links in it, can u detail this?

Thanks man!


------------------
Alex Tutusaus
Atyc WebDesigns
http://www.webcamworld.com/

[This message has been edited by webcamworld (edited July 20, 1999).]
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
The error message is being generated by this line:
Code:
open (RATE, ">$build_ratings_path/$build_index_incl") or &cgierr ("unable to open top rated page: $build_ratings_path/$build_index_incl. Reason: $!");
Just curious, did you assign anything to this variable: $build_index_incl
In links.cfg there is a place to define $build_index. It's just where you tell it what you want the index file to be. (ussually index.shtml or index.html or index.htm)
Change your $build_index_incl both places in the above line to read rate_incl.html instead of making it a variable.
That should get rid of your error message and you should notice that you're halfway there. The file should be located in your /Ratings/ directory.
If you can get to that point, I'll help you with the links display.

I'll check back later today.
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Hi!

Indeed, I didn't do anythin on links.cfg (still not familiar with Links).

But, yes, this worked. I now have the two files.
http://www.camcities.com/Ratings/rate_incl.html

I guess I just need the line where top by #ofvotes are calculated....but let's continue.

What's next? Wink


------------------
Alex Tutusaus
Atyc WebDesigns
http://www.webcamworld.com/

[This message has been edited by webcamworld (edited July 20, 1999).]
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Now you'll go back and modify some of what you've already created.

in nph-builde.pl under sub build_rate_page, notice the line
Code:
$top_votes .= qq~<tr><td align=center>$font$link{'Rating'}</td><td align=center>$font$link{'Votes'}</td><td>$font<a href="$link{'URL'}">$link{'Title'}</a></td></tr>\n~;
and the line
Code:
$top_rated .= qq~<tr><td align=center>$font$link{'Rating'}</td><td align=center>$font$link{'Votes'}</td><td>$font<a href="$link{'URL'}">$link{'Title'}</a></td></tr>\n~;
I've added in a $font variable that you can either define and use or just take out.

You'll need to duplicate these two lines and name them something similar and use the html in your two new lines to set your formatting. Just make sure that the $link{'Votes'} and the other $link stuff is left the same.

Now in site_html_templates.pl go to sub site_html_ratings_inc (your sub) and change the two tag definitions
Code:
top_rated => $top_rated, top_votes => $top_votes,

to whatever you chose to call them earlier in nph-build.pl like:
Code:
top_rated_inc => $top_rated_inc, top_votes_inc => $top_votes_inc,

Then you can use the tags: <%top_votes_inc%> and <%top_rated_inc%> in your new template that you created.

Also, go back to nph-build.pl above the stuff you just modified and copy this line:
Code:
$top_rated = ''; $top_votes = '';
and put in your variables like so:
Code:
$top_rated_inc = ''; $top_votes_inc = '';
It won't work without this! :-)

Now that should do it. Let me know how it goes.

Oh yeah. In your html, just use a numbered list to handle the numbering 1-10.
Code:
<ol>
<li>one
<li>two
</ol>
If you're not familiar with how to do this let me know.
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
jeffo,

Well actually everything seems a bit unorganized ;-)

I think I've made all the changes on site_html_templates.pl but I'm still lost with nph-build.cgi

What do you mean when you say
Code:
<font face="Arial,Helvetica">
<%top_votes_inc%>
</font>

Why putting <li>'s on the template? THis won't affect the result, will it?

Thanks!

------------------
Alex Tutusaus
Atyc WebDesigns
http://www.webcamworld.com/

[This message has been edited by webcamworld (edited July 21, 1999).]
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
I posted the mod to the resource center. Until it gets validated, here's the instructions. After that, I'll come back and delete them here.

Top 10 on front page mod:

Summary:
This mod will pull the top 10 by votes/ratings into the frontpage by creating a separate file from the same data that can be pulled into any page with an ssi call. It could also be inserted with nph-build.pl but that is not covered here.

You'll need to change 2 files:
nph-build.pl
site_html_templates.pl

You'll need to create 1 new template file:
rate_top_include.html

-------------------------------------------------
In nph-build.pl:

1. Go to sub build_rate_page.

2. Below the line:
Code:
$top_rated = ''; $top_votes = '';
Insert:
Code:
#rate include
$top_rated_include = ''; $top_votes_include = '';

3. Below the line that starts with "$top_votes .= qq~....."
Insert:
Code:
#rate include
$top_votes_include .= qq~<li><a href="$link{'URL'}">$link{'Title'}</a> - ($link{'Votes'} votes) Rating: $link{'Rating'} \n~;

4. Below the line that starts with "$top_rated .= qq~........"
Insert:
Code:
#rate include
$top_rated_include .= qq~<li><a href="$link{'URL'}">$link{'Title'}</a> - ($link{'Votes'} votes) Rating: $link{'Rating'} \n~;

5. Below the next section, right after " close RATE;"
Insert:
Code:
#rate include
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 "\tVote Range: $top_votes[0] .. $top_votes[$#top_votes]\n";
print "\tRate Range: $top_rate[0] .. $top_rate[$#top_rate]\n";
print RATE_INCLUDE &site_html_ratings_include;
close RATE_INCLUDE;
-------------------------------------------------
That's it for nph-build.pl. Now on to site_html_templates.pl
-------------------------------------------------
In site_html_templates.pl:

1. Below the sub site_html_ratings,
Insert:
Code:
#rate include
sub site_html_ratings_include {
# --------------------------------------------------------
# This routine determines how the top rated page will look like.

return &load_template ( 'rate_top_include.html', {
top_rated_include => $top_rated_include,
top_votes_include => $top_votes_include,
%globals
});
}

-------------------------------------------------
That's it for site_html_templates.pl. Now on to the template.
-------------------------------------------------
1. Create a new file.

2. Insert the following:
Code:
<b>Top 10 Resources (by Rating) -- with at least 10 votes</b>
<ol>
<%top_rated_include%>
</ol>



<b>Top 10 Resources (by Votes) -- with at least 10 votes</b>

<ol>
<%top_votes_include%>
</ol>

3. Save it as "rate_top_include.html" and put it in your templates directory.

-------------------------------------------------
That's it for the template. No just pull it into your front page.
-------------------------------------------------
1. Just put the ssi call to your file somewhere on your home.html template. Something like:
Code:
<!--#include virtual="/Ratings/rate_include.shtml"-->

2. Build your pages and your top 10 should show up on your home page.

Note: This assumes that you are using the .shtml as your $build_extension (defined in links.cfg. If not, replace all occurances of .shtml with whatever you're using.

-------------------------------------------------
That's it! You're done!
-------------------------------------------------

Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Hi!

Since I just wanted the top 10 by votes to appear on the homepage, I just used the "vote" parts everywhere but:

What if I dont have SSI capabilities?

I succesfully create:
http://camcities.com/Ratings/rate_include.html

So now I just need to
1) Give format to it
2) Put it in the home.html template

Any chances without SSI?

Thanks 4 everyting!

------------------
Alex Tutusaus
Atyc WebDesigns
http://www.webcamworld.com/
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
It works without ssi but you have to build the database twice. It's kind of a workaround. I'll post it after lunch.
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
At the bottom of site_html_templates.pl put this sub routine:
Code:
sub get_top_include {
# --------------------------------------------------------
my $top_include;
open (TOP_INCLUDE, "<$build_ratings_path/rate_include$build_extension")
or &cgierr("unable to open file: $build_ratings_path/rate_include$build_extension. Reason: $!");
while (<TOP_INCLUDE> )
{ $top_include .= $_; }
close TOP_INCLUDE;
return $top_include;
}

Somewhere at the top of site_html_templates.pl above the globals section put this line:
Code:
$top_include = &get_top_include;

Then in the globals section add this:
Code:
top_include => $top_include,

Then in your home.html template wherever you want to put the top 10 list put this tag:
Code:
<%top_include%>

I like this mod but the disadvantage is that you have to build twice.
The reason for this is that the script is creating the file and then trying to pull it in as a tag in the same call.
It would be good if we could build the include_file first, then build-all. But for now, just build twice.
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Hi!

Great, have it working at

http://www.camcities.com/Ratings/

as a test page.

Will play in nph-build.cgi for customization.

If you ever find how not to rebuild twice, please let me know.

Thanks man!


------------------
Alex Tutusaus
Atyc WebDesigns
http://www.webcamworld.com/

[This message has been edited by webcamworld (edited July 22, 1999).]

[This message has been edited by webcamworld (edited July 22, 1999).]
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
solved this problem... wondering if someone can help with the one below

[This message has been edited by padders (edited August 21, 1999).]
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
The other thing, is there a way of making the url the one that goes through the cgi program so that it is still counted?

Thanks

------------------
-------------------------
http://www.freeontheweb.com/
Reviewed and rated resources for webmasters
-------------------------
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
padders,

Try replacing:
$link{URL}

With:
$db_cgi_url/jump.cgi?ID=$link{'ID'}

It works on my site,
Sheldon

------------------
webmaster@gottabounce.com
www.gottabounce.com

Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Thank you, i will try it

------------------
-------------------------
http://www.freeontheweb.com/
Reviewed and rated resources for webmasters
-------------------------
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
I found this thread showing how to set a max number of sites to return for the top ten list ( http://www.gossamer-threads.com/...um3/HTML/002149.html and was wondering if it could be used in a different way. What I'd like is to have the includes on my home page list the top 5 while the Rate page still lists the top 10. Anyone have any ideas on how to do this?

Thanks,
Sheldon

------------------
webmaster@gottabounce.com
www.gottabounce.com

Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Hi!

Is there any way I could block certain sites to appear in this listing? (More specificly, those contained in the 'Adult_Sites' subcategories...)


------------------
Alex Tutusaus
Atyc WebDesigns
http://www.webcamworld.com/
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Any1 out there?


------------------
Alex Tutusaus
Atyc WebDesigns
http://www.webcamworld.com/
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
how can I make numbers appear before the links???? what I meen is this:
1)X
2)XX
3)XXX

THEULS

------------------
---------------------------------------
http://www.surfootball.com
The soccer index
------------------------------------
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
could somebody please help????


THEULS


------------------
---------------------------------------
http://www.surfootball.com
The soccer index
------------------------------------
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Add <ol> before the <li> code and the add </ol> after the </li> code.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Hi!
I looked at my code and i don't find <li>

Here's part of code


<table border="0">
<tr>
<th width="88"><strong><font face="verdana" size="2">Ocena</font></strong></th>
<th width="88"><strong><font face="verdana" size="2"># Glasovi</font></strong></th>
<th width="170"align="left"><strong><font face="verdana" size="2">Povezava</font></strong></th>
</tr>
<font face="verdana" size="2"><%top_rated%></font>
</table>


where should i put those ol and li?

thanx in advance


Gregor
www.vstopnice.com
www.balonarstvo.com
www.e-nepremicnine.com
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
The code you posted is not very useful. What's the code your using to build the <%top_rated%>?



Good Luck!

Glenn
Host Links
http://cgi-resource.co.uk/links
Quote Reply
Re: How can I put only the top 10 sites (by votes) on the homepage? In reply to
Hi!
here's my part of nph-build.cgi


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

my (@values, $id, $votes, $rate, @top_votes, %top_votes, @top_rate, %top_rate);
local ($top_rated, $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];
$votes = $values[$db_votes];
$rate = $values[$db_rating];
next if ($votes < 3);
if (($#top_votes < 99) or ($votes > $top_votes[$#top_votes])) {
push (@{$top_votes{$votes}}, @values);
if ($#top_votes <= 100) {
push (@top_votes, $votes);
@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] = $votes;
@top_votes = sort { $b <=> $a } @top_votes;
}
}
if (($#top_rate < 99) or ($rate > $top_rate[$#top_rate])) {
push (@{$top_rate{$rate}}, @values);
if ($#top_rate <= 100) {
push (@top_rate, $rate);
@top_rate = sort { $b <=> $a } @top_rate;
}
else {
splice (@{$top_rate{$#top_rate}}, 0, $#db_cols);
$#{$top_rate{$#top_rate}} or delete $top_rate{$#top_rate};
delete $top_rate{$top_rate[$#top_rate]-$id};
$top_rate[$#top_rate] = $rate;
@top_rate = sort { $b <=> $a } @top_rate;
}
}
}
close LINKS;

$top_rated = ''; $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{'Rating'}</td><td align=center>$link{'Votes'}</td><td><a href="$link{'URL'}"TARGET=”_blank”>$link{'Title'}</a></td table width="80%" font face="Verdana" align="center" border="0" cellspacing="2" cellpadding="2"></tr>\n~;
}
foreach (sort { $b <=> $a } @top_rate) {
$seen{$_}++;
%link = &array_to_hash ($seen{$_} - 1, @{$top_rate{$_}});
$top_rated .= qq~<tr><td align=center>$link{'Rating'}</td><td align=center>$link{'Votes'}</td><td><a href="$link{'URL'}"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 "\tRate Range: $top_rate[0] .. $top_rate[$#top_rate]\n";
print RATE &site_html_ratings;
close RATE;
}


is this what you wanted to see?

thanx

Gregor
www.vstopnice.com
www.balonarstvo.com
www.e-nepremicnine.com
> >