Gossamer Forum
Home : Products : Links 2.0 : Customization :

Rating with stars

Quote Reply
Rating with stars
I called my self searching the forum to find how to place star in front of links according to rate. I found this

http://www.asan.com/users/phoenix/mod-ratings.html

it's what I want but it is for templates... Does only one know how to do this by editing site_html.pl?

Quote Reply
Re: Rating with stars In reply to
Widgetz wrote a much nicer Mod that uses less codes and produces the same results. I tried searching the forum for the codes, but could not find them, so I will re-post them here:

1) Add this new sub to the bottom of your site_html.pl file:

Code:
sub get_rating_image {
#-----------------------------------------------------
my ($rating) = @_;
my ($i, $image);
for ($i = 0; $i <= 20; $i++) {
$image = qq~<img src="$rating_images_url/rate$i.gif" alt="$rating" border="0">~ and last if ($rating <= $i/2);
}
return $image | | $rating;
}

2) Add the following codes in your sub site_html_link routine in the site_html.pl file:

Code:
$rate_img = &get_rating_image($rec{'Rating'});

at the top of the sub.

3) Add the following codes in the HTML section of the sub site_html_link:

Code:
$rate_img

4) Add the following variable definition in your links.cfg file:

Code:
$rating_images_url = "http://www.yourdomain.com/images/";

5) Upload 20 ratings graphics to your images directory, like the following:

rate0.gif
rate1.gif
rate2.gif
rate3.gif

etc.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited February 26, 2000).]
Quote Reply
Re: Rating with stars In reply to
Thanks I will try this... Can this be added to the resource center... this is usually where I check for these great modifications.
Quote Reply
Re: Rating with stars In reply to
It was written by Widgetz...and it is up to Mod Authors to add Modifications to the Resource Center.

And the second place to check for Modifications is in this forum where I found the codes!!!!!!!

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Rating with stars In reply to
Ok I am getting this error! I must have missed something? It is promting me to download I open it and I get this:

Error including libraries: syntax error at /home/referra/public_html/adminreferral/cgi-bin/admin/site_html.pl line 115, near ")

$build_detailed "

Make sure they exist, permissions are set properly, and paths are set correctly.

ok it just error when I did this code it this right? Cliped from site_html.pl

sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like. It's a little complex looking just because we have to
# check for blank entries..


my (%rec) = @_;
$rate_img = &get_rating_image($rec{'Rating'})

$build_detailed ?
($output = qq~<ul><li>($output = qq~<ul><li> $rate_img <a href="$rec{'URL'}">$rec{'Title'}</a>~) :
($output = qq~<ul><li>($output = qq~<ul><li> $rate_img <a href="$rec{'URL'}">$rec{'Title'}</a>~);



if ($rec{'Description'}) { $output .= qq~ <span class="descript">- $rec{'Description'}</span>\n~; }
if ($rec{'isNew'} eq "Yes") { $output .= qq~ <small><sup class="new">new</sup></small>~; }
if ($rec{'isPopular'} eq "Yes") { $output .= qq~ <small><sup class="pop">pop</sup></small>~; }

$output .= qq~ <small class="date">(Added: $rec{'Date'} Hits: $rec{'Hits'} Rating: $rec{'Rating'} Votes: $rec{'Votes'}) <a href="$build_rate_url?ID=$rec{'ID'}">Rate It</a></small>
</ul>
~;

return $output;
}


Here is cliping from links.cfg

# This script is not freeware! Please read the README for full details
# on registration and terms of use.
# =====================================================================

# Modified for stars where is the directory
$rating_images_url = "http://www.referralmaker.com/adminreferral/images";

# Paths and URL's to Important Stuff
# --------------------------------------------------------


Where did I go wrong?


------------------
David Eaton
The Freebie Site
http://www.thefreebiesite.com
Quote Reply
Re: Rating with stars In reply to
forgot I did add this sub to site_html.pl

next to the last sub! I did not put it last becasue I did not know what 1; meant.


sub get_rating_image {
#-----------------------------------------------------
my ($rating) = @_;
my ($i, $image);
for ($i = 0; $i <= 20; $i++) {
$image = qq~<img src="$rating_images_url/rate$i.gif" alt="$rating" border="0">~ and last if ($rating <= $i/2);
}
return $image | | $rating;
}





sub site_html_rate_failure {
# --------------------------------------------------------
# This routine determines how the rate failure page will look like. You have
# access to the following variables:
#
# $errormsg : A bulleted list of the problems.
#

my $errormsg = shift;

&html_print_headers;
print qq~
<$dtd>
<html>

<head>
<title>$site_title: Error Rating Resource.</title>
<$css>
</head>

<$site_body>

<h1>$site_title: Error Rating Resource</h1>

$site_menu

<p>Sorry, but we were unable to rate the resource for the following reason:
<p><strong class="error">
$errormsg
</strong></p>
<p>Please contact the site administrator if you have any questions.</p>

$site_search
$site_footer

</body>
</html>
~;

}
1;

------------------
David Eaton
The Freebie Site
http://www.thefreebiesite.com
Quote Reply
Re: Rating with stars In reply to
Okay...

Add a semi-colon at the end of the following line of codes:

Code:
$rate_img = &get_rating_image($rec{'Rating'})

Like the following:

Code:
$rate_img = &get_rating_image($rec{'Rating'});

That should take care of the syntax error.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Rating with stars In reply to
I am still getting this error

Error including libraries: syntax error at /home/referra/public_html/adminreferral/cgi-bin/admin/site_html.pl line 116, near "ul>"

Make sure they exist, permissions are set properly, and paths are set correctly.

it promots me to download.

I upload the updated site_html.pl

and reload my browser just to make sure..


------------------
David Eaton
The Freebie Site
http://www.thefreebiesite.com
Quote Reply
Re: Rating with stars In reply to
I see the error instead of 115 it's 116 here is that sub again from site_html.pl

sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like. It's a little complex looking just because we have to
# check for blank entries..


my (%rec) = @_;
$rate_img = &get_rating_image($rec{'Rating'});

$build_detailed ?
($output = qq~<ul><li>($output = qq~<ul><li> $rate_img <a href="$rec{'URL'}">$rec{'Title'}</a>~) :
($output = qq~<ul><li>($output = qq~<ul><li> $rate_img <a href="$rec{'URL'}">$rec{'Title'}</a>~);



if ($rec{'Description'}) { $output .= qq~ <span class="descript">- $rec{'Description'}</span>\n~; }
if ($rec{'isNew'} eq "Yes") { $output .= qq~ <small><sup class="new">new</sup></small>~; }
if ($rec{'isPopular'} eq "Yes") { $output .= qq~ <small><sup class="pop">pop</sup></small>~; }

$output .= qq~ <small class="date">(Added: $rec{'Date'} Hits: $rec{'Hits'} Rating: $rec{'Rating'} Votes: $rec{'Votes'}) <a href="$build_rate_url?ID=$rec{'ID'}">Rate It</a></small>
</ul>
~;

return $output;
}



------------------
David Eaton
The Freebie Site
http://www.thefreebiesite.com
Quote Reply
Re: Rating with stars In reply to
ok... i thought people would know this by now..

the "&#0124; &#0124;" need to be closed...

ie:

||

this forum screws it up..

------------------
Jerry Su
Links SQL User
------------------
Quote Reply
Re: Rating with stars In reply to
If I did something wrong to messup the forum I am sorry I did not know!

I enjoy this forum I don't want to mess it up sorry man.

How does the code look above what's wrong with it
Quote Reply
Re: Rating with stars In reply to
It is not you, UBB messes codes up when they are printed in the forum...

AS widgetz mentioned, just close up the space between the two |.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Rating with stars In reply to
ok I will try to watch it... I am still having trouble instead of posting the site_html.pl to the forum I renamed the file site_html.txt so you can see it Maybe catch my mistake..

http://www.referralmaker.com/adminreferral/cgi-bin/admin/site_html.txt

Admin is not protected

------------------
David Eaton
The Freebie Site
http://www.thefreebiesite.com
Quote Reply
Re: Rating with stars In reply to
Copy these codes EXACTLY:

$rate_img = &get_rating_image($rec{'Rating'});

Then REPLACE them with the ones you have in your site_html.pl. (There should not be a space between the ) and ;.)

REPLACE the following:

Code:
return $image | | $rating;

WITH the following:

Code:
return $image &#0124; &#0124; $rating;

There should be NO SPACE betweent the two |.

Click on the Edit icon of my reply to copy the exact codes, if you have problems copying the codes from the screen. Go to the textbox in my reply (after clicking on the EDIT icon, and copy the codes in the textbox)!

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Rating with stars In reply to
I found what was wrong... Your Code for Stars works like a dream...

I was tring to modify the code so the Url would show instead of jump=id showing... this string below worked but when I installed stars it throw everything off!

$build_detailed ?
($output = qq~<ul><li>($output = qq~<ul><li> $rate_img <a href="$rec{'URL'}">$rec{'Title'}</a>~) :
($output = qq~<ul><li>($output = qq~<ul><li> $rate_img <a href="$rec{'URL'}">$rec{'Title'}</a>~);

This is what is should have been!

$build_detailed ?
($output = qq~<ul><li><a class="link" href="$build_detail_url/$rec{$db_key}$build_extension">$rec{'Title'}</a>~) :
($output = qq~<ul><li>$rate_img<a class="link" href="$rec{'URL'}">$rec{'Title'}</a>~);

Now it works perfect!

I have another question How Do I sort the links by rank?

I searched the forum and found something that said to change link.def to

# Field number to sort links by:
$db_sort_links = 12;

well this did not work!

My goal to to have the most ranked on top!
I don't want the New Or popular links on top!

Can this be done?




------------------
David Eaton
The Freebie Site
http://www.thefreebiesite.com
Quote Reply
Re: Rating with stars In reply to
Ok I under stand what you was saying about the foruam and the spaces now....

On site_html.pl I took out the space..

Guys I am still getting the same error..

Error including libraries: syntax error at /home/referra/public_html/adminreferral/cgi-bin/admin/site_html.pl line 117, near "ul>"

Make sure they exist, permissions are set properly, and paths are set correctly.

Is the error....above...

I updated site_html.pl and site_html.txt so you can see it..

117 is around here

my (%rec) = @_;

$rate_img = &get_rating_image($rec{'Rating'});

$build_detailed ?

I change links.cfg to linkscfg.txt so you can see it is this correct?

I placed the star directory on top!

here is both links:
http://www.referralmaker.com/adminreferral/cgi-bin/admin/site_html.txt

http://www.referralmaker.com/adminreferral/cgi-bin/admin/linkscfg.txt



------------------
David Eaton
The Freebie Site
http://www.thefreebiesite.com
Quote Reply
Re: Rating with stars In reply to
Try remming out or commenting out the following codes:

Code:
$rate_img = &get_rating_image($rec{'Rating'});

And see if the problems still occur. If not, then these codes may need to go outside of the sub site_html_link and be put under the time = &get_time; codes.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Rating with stars In reply to
Uh...I think you answered your own question in the other Topic you created.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums