Gossamer Forum
Home : Products : Links 2.0 : Customization :

New mod: Ratings breakdown

Quote Reply
New mod: Ratings breakdown
I have finished and posted the first ratings breakdown mod up on my site. This one is useful for those who have various site stats on their main page. It displays graphically a breakdown of all the ratings given by visitors.

I'm also close to getting the second ratings breakdown mod working. That will give a break down of ratings given for each link.

Also when I get time I'll post instructions on how to have a quote/message displayed on your site. That visitors can change. Not sure if anyone will use this one but it's quite simple and helps make a site more interactive.


Good Luck!

Glenn

http://mir.spaceports.com/~glennu/
Quote Reply
Re: New mod: Ratings breakdown In reply to
Hi,
nice mod. But instead of putting

if ($rating eq 2) {
open (ID, "<rate2.db ") or &cgierr("error in process_form. unable to open id file: vote1.db. Reason: $!");
$numberc = <ID> + 1; # Get next ID number
close ID;
# Update the counter.
open (ID, "> rate2.db ") or &cgierr("error in get_defaults. unable to open id file: vote1.db. Reason: $!");
flock(ID, 2) unless (!$db_use_flock);
print ID "$numberc"; # update counter.
close ID; # automatically removes file lock
&site_html_rate_success;
}

10 times into rate.cgi, why not saying

@vote_range = ( '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '10' );
foreach $number (@vote_range) {
if ($rating eq $number) {
open (ID, "<rate$number.db ") or &cgierr("error in process_form. unable to open id file: vote$number.db. Reason: $!");
$numberc = <ID> + 1; # Get next ID number
close ID;
# Update the counter.
open (ID, "> rate$number.db ") or &cgierr("error in get_defaults. unable to open id file: vote$number.db. Reason: $!");
flock(ID, 2) unless (!$db_use_flock);
print ID "$numberc"; # update counter.
close ID; # automatically removes file lock
&site_html_rate_success;
}
}

Taking this straight out of my gray brain I hope this should work... Wink
If you try it, pls. let me know if it worked... Tks.
Ciao
Denis

(PS: wanted to send you a 'private Mail' about this, but seems you turned this option off...?)


Quote Reply
Re: New mod: Ratings breakdown In reply to
I've got the second ratings breakdown mod working and will post it on my site either tonight or tommorrow.

It gives a breakdown of the ratings given for each link graphically.

Useful if you use a detailed page. This version will also display the total ratings breakdown on your main page like the first one.


I wouldn't recommend installing it if your relatively new to links 2. Cause it does involve quite a bit of installing. Ie. to install it you have to edit links.cfg, links.def, nph_build.cgi, rate.cgi, and site_html_templates and add 5 new fields to links.db


Good Luck!

Glenn

http://mir.spaceports.com/~glennu/
Quote Reply
Re: New mod: Ratings breakdown In reply to
Yeah that would be better/shorter code to use. Thanks I'll alter it accordingly and give you some credit for it.

There's quite a few pieces of code which could be made shorter. I just wrote it just to get it to work first and then hopefully when I get some more time I'll make it shorter and improve bits.

I don't have much spare time at the moment so there's lots of bits I'd like to improve or do better but I have to put it on hold a bit untill I finish work for the summer.

I took the private messages off mainly because I was getting alot of questions that really should have gone into the forum instead of to me. I prefer answering questions about scripts in the forum cause then others can see what to do etc...

Of course in this case a private message would have been better. Sorry about that, I'll enable it again.

Good Luck!

Glenn

http://mir.spaceports.com/~glennu/
Quote Reply
Re: New mod: Ratings breakdown In reply to
Thanks for taking the time to look through it and thanks for giving your input.

I'll change it sometime next week and let you know if it works. It looks like it should work.



Good Luck!

Glenn

http://mir.spaceports.com/~glennu/
Quote Reply
Re: New mod: Ratings breakdown In reply to
To make that just a smidgen shorter...

instead of:
Code:
@vote_range = ( '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '10' );
use:
Code:
@vote_range = (1..10);
--Drew
Quote Reply
Re: New mod: Ratings breakdown In reply to
Cool, that's how I'm learning. Thanks for your hint, junko...

Denis

Quote Reply
Re: New mod: Ratings breakdown In reply to
Trial and error is one of the best ways to learn. I've started to learn a lot about Perl from piddling around with Links in the past couple weeks and I'm about 150 pages through a 700 page tutorial.

--Drew
Quote Reply
Re: New mod: Ratings breakdown In reply to
'Cool, that's how I'm learning. Thanks for your hint, junko...'


Yeah same here. It's amazing how much can be picked up by just messing around with Links.

I'd also like to get a book and do some tutorials.

Junko, can you recommend any good books or websites?

Good Luck!

Glenn

http://mir.spaceports.com/~glennu/
Quote Reply
Re: New mod: Ratings breakdown In reply to
Glennu,

I'm using "SAMS Teach Yourself Perl in 21 Days" by Laura Lemay. It's an okay book, but it makes too many references to "C" (assuming any programming experience you had MUST have been with C) when explaining how things work. The book also has a website, http://www.typerl.com.

--Drew
Quote Reply
Re: New mod: Ratings breakdown In reply to
I have tried to install the script in Glenn's original version. Unfortunately, I receive a persistent "unable to open id file: rate1.db" msg. I have uploaded the .db files, cannot find the reason for that error. Any ideas?

Quote Reply
Re: New mod: Ratings breakdown In reply to
Yeah I'm affraid I put the scripts up and haven't had the time yet to improve bits, improve the instructions etc..... I take it you tried to install the total ratings breakdown.

The error message you go unable to open rate1.db means it's looking for a rate1.db in the same directory as rate.cgi but can't find it. (ie it's either in the wrong path or the permissions are wrong.). If you decide to put the rate1.db etc.. in a different directory to rat.cgi make sure you change the paths in the scripts and also chmod that directory to 777.

I would do the following

Check the paths and permissions are correct.

(I'll prob put this on my site soon)You could define the paths to the databases in links.cfg at the bottom give them names like db_rates1_path

then use them names instead of rates1 etc..... in rate.cgi
(no different to the first option, it just means it'll be easier to alter the paths at a latter date if you need to)

Also (although optional) I reset the ratings and votes on my site to 0 so that the breakdown of ratings tallied with the number of votes and av rating.

I'll have more spare time after next week so I'll clean up some bits then. However what's up there now will work.....

Good Luck!

Glenn

http://mir.spaceports.com/~glennu/
Quote Reply
Re: New mod: Ratings breakdown In reply to
Paths and permissions are ok, otherwise I would not have dared to post... Wink

I'll follow your advice defining paths in links.cfg, perhaps it works. Anyhow, can't wait to get that working, it's a great add-on!

Quote Reply
Re: New mod: Ratings breakdown In reply to
Were the problems happening when you went to rate a site or when you went to build your site? All I can say is check the paths in both rate.cgi site_html_templates.pl cause that error message can't mean anything else.

Good luck and I really hope you get it working!


Glenn

http://mir.spaceports.com/~glennu/
Quote Reply
Re: New mod: Ratings breakdown In reply to
I am still getting that "process_form" error. I understand that with your original configuration (uploading rates1.db to rates10.db into the same directory as rate.cgi as well as setting the .db permissions to 666), it should work. Guess that perl dummy of mine has to be waiting for your improved version... Laugh

Quote Reply
Re: New mod: Ratings breakdown In reply to
No problem, I'll make a few changes next week and post a message here when I've done it.

Good Luck!

Glenn

http://mir.spaceports.com/~glennu/
Quote Reply
Re: New mod: Ratings breakdown In reply to
Still struggling with the installation... Tongue

Now I keep on receiving the following error msg:

Code:
"Fatal error: Illegal division by zero at blablabla/site_html_templates.pl line ..."
The referenced line is

Code:
$totr1 = $n1 / $ttotal;
Thomas
http://www.japanreference.com
Quote Reply
Re: New mod: Ratings breakdown In reply to
Incase anyone else is having the same problem. I've posted the updated code on my website. Just copy the new site_html_templates code.

Good Luck!

Glenn


http://mir.spaceports.com/~glennu/
Quote Reply
Re: New mod: Ratings breakdown In reply to
Glenn,

Nice mod. I would like to be able to install this mod except I am unable to find Bobsies file that is required. and instructions.
Any guidance would be greatly appreciated.

Thanks

George

Quote Reply
Re: New mod: Ratings breakdown In reply to
Below is where the upgrade script is:

http://gossamer-threads.com/perl/forum/showflat.pl?ubb=001090:Forum3

Just change the field number to the one you want to add and make sure the value is adds to each field is 0. (Back up links.db before running it!)




Good Luck!

Glenn


http://mir.spaceports.com/~glennu/
Quote Reply
Re: New mod: Ratings breakdown In reply to
Glenn,

Any hint where I can get the image required?

Thanks,

George

Quote Reply
Re: New mod: Ratings breakdown In reply to
You can either make one or download the image on my site here:

http://mir.spaceports.com/~glennu/ratingsbreak2.html

Good Luck!

Glenn


http://mir.spaceports.com/~glennu/