02/03/07
Inroduction
css_rating is a Ajax rating system for Textpattern based on Unobtrusive AJAX Star Rating Bar
Features
- uses CSS for voting bar
- IP limiting
- scalable voting bar 1 to 10 units
- uses Ajax
Usage and Tags
<txp:css_rating_bar /> is used to draw voting bar
Attributes:
- id: default is current article id (uses $thisarticle[‘thisid’]) and most of the cases you don’t have to specify this. If you want to show rating bar for a diffent article find its article id on articles list. e.g. on index: vote for my awsome “AAA Titled” article
<txp:css_rating_bar id="x" />where “x” is my “AAA Titled” article id (integer) - units: number of rating units you want to use, default is 10. 10 is upper limit.
- unitwidth: Width of a rating unit in pixel, default is 30. Note that unitwidth is not used for styling, in rating.css default value 30px used so if you change it you shoul edit the rating style sheet
- firstvote: Give your fist vote for all articles, default 7
<txp:css_rating_js /> is used for neccesary javascript and css files. This should be placed in <head> </head> tags
Attributes:
- js: default is empty, it used for uploaded .js file id
Installation:
- Upload css_rating_sql.php
and rating.phpto your Textpattern directory. (You can skip this see 8) - Upload 2 images in images folder to images directory.
- Upload the rpc.php to root directory (it handles ajax requests)
- Go to css_rating_sql.php e.g. http://www.yoursite.com/textpattern/css_rating_sql.php
- Delete css_rating_sql.php when you get the success message
- Install css_rating
- Upload the rating.js file in files folder via Textpattern interface or directly to files folder.
- Creating Rating MySQL table (Optional, skip this if you do 1. step) Following table is used for rating data you can run this sql code via phpMyAdmin
CREATE TABLE IF NOT EXISTS `txp_ratings` ( `id` int(10) unsigned NOT NULL, `total_votes` int(10) unsigned NOT NULL, `total_value` int(10) unsigned NOT NULL, `used_ips` longtext NOT NULL, PRIMARY KEY (`id`) ) TYPE=MyISAM;
Download
css_rating.zip 12 KB
Demo
<txp:css_rating_bar id="84" units="8"/>
<txp:css_rating_bar id="80" units="5" />

Now here is a plugin i might actually use … good job …
Hi, thank you for this. Note: if you use clean URL, you should have in css rater than ../images some like this /images/
Thank you, just what I was looking for!
But I miss something… Whats the point of rate stuff if you don’t have a top ten list or something? Is there any chans that you or anybody can do a plugin to show some statisticts for the ratings?
Jan Rozehnal: thank you for the tip
The Magnus: I also need something like that, list by rating and top rated items will come so soon
Awsome. Please let me know when if the statistic plugin is ready. =)
Thank you again.
hi there,
i’m trying to use your plugin, and i keep getting this error:
tag_error -> Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource on line 299
everything appears to be working, though, which is strange. any ideas?
hi dave,
I think it is my fault, I have written this plugin on Production Status: live so I haven’t seen any warning.
I will fix it for the next version. You can set Production Status to live at Admin -> Preferences not to see that warning.
Thank you
ah yes. i had just done a fresh install of txp, and forgot to set the production status to live. thanks for the tip!
Hello,
thank you for this nice plugin. I can’t say I’ll use it for now, but luckly now I know where to look :)
I’m looking forward to statistic plugin ;)
I will dl it and try it on my local dev server.
Cheerz m8z,
Pedja
I installed the CSS Ratings pluging and it’s gone a bit wierd. Followed the instructions, but no idea what is wrong. could you take a look at: http://takuhii.x10hosting.com/
hello Predrag Drljaca, you are welcome,
Darren Mackintosh: It seems working but necessary styles are missing. You can copy/paste content of rating.css to Presentation > Style > Default.
Thank you for the help, it works now. Going to try and shrink the size of the stars
Hello. First of all, thank you, this plugin is great.
I installed the plugin and set units to 5 stars, but… in posts to rate I see 6 stars. =S
Any ideas?
(Sorry, my English is poor)
hi JEL,
I have tested the plugin with five star and I got the same problem because of “firstvote” option. If the firstvote is bigger than number of units that problem occurs.
You can set something like this
<txp: css_rating_bar units=“5” firstvote=“3” />PS. No problem my english is not great also :)
Mkavici, thank you by your answer.
What is the code I can set? I can’t see it in your comment.
I set units=“5” firstvote=“3” in my post form, but error persist.
Would I change the plugin code, with units=“5” and firstvote=“3” in the “plugin” section?
Or re-install the entire plugin from 0? Drop “ratings” table in the DB, etc.?
Thanks in advance.
JEL,
I have looked your site again and realised that it is because of styling.
.texto ul {margin:0.3em 0pt 1.5em;
padding:0pt 6% 0pt 20px;
}
You can add this line to your style sheet
.ratingblock ul{padding:0}Mkavici:
Yeah! Now it works all right!
Very, very, very thank you!!! =)
Hi
Thanks for your work on this plugin,
I have installed ok, but when a user votes I get a list of numbers showing up under the stars, this lasts until the page is refreshed. any ideas as to what is causing this?
You can see here: http://res72.com/2006/
hi Peter,
I think that is because of styles. I can see that text-intent property is missing for unit_rating class.
.unit-rating li {
margin:0px;
padding:0px;
text-indent:-9000px;
}
This is totally brilliant and a great way to help keep Textpattern in touch with all the AJAX that flying around out there! You bet I’ll be keeping my eyes on this.
@ mkavici
Thanks for your eagle eyes dude!, its always the little things that end up frustrating me.
Hey there M!
Many thanks indeed for this little gem. I’m using it for my customers to be able to rate the real ales we have on tap. They change every week so I’d like to know what they like and what I could maybe order again in the future.
One problem though, the IP checker is a little inconvenient for my purposes as we have two ethernet connections in the bar and also WLAN connectivity available. All of these connect to a router and then to the internet, thus all connections made in the bar are behind 1 IP. I’d like my customers to be able to rate the beer while they’re drinking it so is there anyway to turn it off?
Many thanks again though, I love the graphical work that it does!
Simon.
Hi Simon,
I got the problem but there is no way to disable ip checking yet. But it is a nice idea for the upcoming version.
Thank you for the suggestion
Great plugin. After a bit of work I was able to get it functioning. I see a few bugs that I will try to work out with the style. Are you planning to make some changes?
Bob,
yes I will make some changes and add some news functions such as most rated statistics, cookie based control ..
Great plugin :)
For the next version, would it be possible to have more options for layout? I would like to omit the text and just display the stars, for example.
Cheers,
Loz
Hi,
Great plugin. Can you please take a look and see why this is not working. This is the test page: http://www.sevefanclub.com/rating
Another thing, is it possible somehow to reset the votes?
Thank you!
Loz, thank you. I will keep in mind your sugestion for the next version :)
Fuls, I think there is a problem with your textpattern installation. i.e. you must have renamed textpattern directory. In rpc.php some files such as config.php included from textpatten directory. And you might have forgotton to run the sql script.
You can reset votes via phpmyadmin by deleting the specific row or truncating the table txp_rating.
great plugin!
Is there now any possibility to sort articles by most rated and least rated?
Hi, mmm dunno… I had already written here but seems to be gone… anyway: great plugin.
I wanted to ask you if there’s a way to sort articles by vote. Like: most voted or least voted..?
thank you, again!
Could this plugin be adapted to add ratings for files that have been uploaded to textpattern?
mkavici, I’ve requested a plugin in the Textpattern forums for ‘Amazon-like Article Reviews’.
The difference with what you have produced is that people rate when submitting a comment and not on the article directly. An average score would be published on the article. More info here:
http://forum.textpattern.com/viewtopic.php?id=22293
Any chance that you can develop this? I’m happy to pay for this or donate money to the Textpattern cause :)
This does not work if Textpattern is not installed in my root-directory?
How to migrate of tcm_rating to css_ratings?
Thanks!.
Sorry for late responses, I was busy for a couple of weeks
feragnoli : yes, it is possible to sort by rating but it will be available for the next version.
Andrew Swihart: I think it can be, as you can specify id. But you should alter the txp_rating table
ALTER TABLE `txp_ratings` CHANGE `id` `id` VARCHAR(10) NOT NULLthen you can use like this
<txp:css_rating_bar id=“f80” units=“5” firstvote=“5”/>where f80 stands for the file with id 80Loz: This is very nice suggestion, I will keep in mind this for the next version.
Rolograaf : Yes it doesn’t work, but you can fix it.
rating.js on line 61 : xmlhttp.open(‘get’, ‘ /rpc.php?v=’+vote); change /rpc.php to your subdirectory such as /blog/rpc.php
Rigel : Let me have a look, I will suggest something if I can find a way to migrate.
Rigel: It is possible to migrate of course but needs some work as they uses different approach.
tcm_rating stores every rate as a row with timestamp but css_rating stores one row for each rate without timestamp. That means you should write a small script to migrate data. It seems impossible to migrate manualy.
Thanks for answering, a new Job always takes so much of your energy!
I cannot seem to debug this problem, with your suggestion I now finally can vote, but the vote is not remembered, next time I visit the page, it is empty again.
I have changed some more occurences that pointed to the root, but probably still missed the important ones.
Maybe, for a next version, you can rewrite so this plugin will use the Textpattern directory instead the root?
congrats on your new job :) do you know approximately when will the next version be released?
Excellent! I’m glad I ran into this plugin, it will come in useful!
Using you fantastic plugin over at welovetxp.com, Thank you!
Where do I get the “rating.php” file? It wasn’t in the zip.
Thanks for the great plugin!
@Tom, it is my mistake there is no such file rating.php ( I used that file when developing the plugin )
thanks for the correction :)
Darn, my first attempt at installing resulted in teh following error:
tag_error <txp:css_rating_bar/> -> Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource on line 299
Any idea how to resolve? I’m a newbie so please provide specifics….me not so smart
@Alan: make sure that you have the “txp_rating” table on your database then you can set Production Status to live at Admin -> Preferences not to see that warning.
ok, that fixed the SQL error (thanks). However, I am still trying to get it to work. I’m using the following:
<txp:css_rating_bar id=“84” units=“5”/>
The results are textual instead of the stars (stacked vertically). That makes me think it’s not finding the images. I’ve got them stored in the images directory though (starrating.gif/working.gif in C:\wamp\www\images and just in case: C:\wamp\www\textpattern\txp_img).
ideas?
also, when i click one of the text numbers to vote, i get a javascript “object not found on line 1) error….i did upload the .js file via the FILES tab in TXP….hope that helps narrow down the options
I also just installed the plug-in and am having the same issue. I am using TXP 4.05 and i get 1-5 rating and no images plus an error. Does anyone know how to fix that?
Great plugin! Are there any news regarding the “best rated / most rated” feature?
I’ve successfully installed this on a testing server. I have it set up with TextCommerce so that products can be voted for. I voted on one product, but now cannot vote on any other products. Is that because of the way the IP checker works on a local install? Should I expect it to behave normally on a live server?
@Raina, I think, you have used id attribute for the txp:css_rating_bar tag. That means you try to vote for the same article. Default value of id is current article id which is uniqe if you don’t set it.