txp:css_rating

01/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:

  1. Upload css_rating_sql.php and rating.php to your Textpattern directory. (You can skip this see 8)
  2. Upload 2 images in images folder to images directory.
  3. Upload the rpc.php to root directory (it handles ajax requests)
  4. Go to css_rating_sql.php e.g. http://www.yoursite.com/textpattern/css_rating_sql.php
  5. Delete css_rating_sql.php when you get the success message
  6. Install css_rating
  7. Upload the rating.js file in files folder via Textpattern interface or directly to files folder.
  8. 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"/>

Rating: 5.9 (357 votes)

<txp:css_rating_bar id="80" units="5" />

Rating: 3.9 (269 votes)

Comments [55]

Yorumlar

  1. DannyB    1248 days ago    #

    Now here is a plugin i might actually use … good job …

  2. Jan Rozehnal    1247 days ago    #

    Hi, thank you for this. Note: if you use clean URL, you should have in css rater than ../images some like this /images/

  3. — The Magnus    1246 days ago    #

    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?

  4. mkavici    1245 days ago    #

    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

  5. — The Magnus    1245 days ago    #

    Awsome. Please let me know when if the statistic plugin is ready. =)
    Thank you again.

  6. dave    1242 days ago    #

    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?

  7. mkavici    1242 days ago    #

    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

  8. dave    1242 days ago    #

    ah yes. i had just done a fresh install of txp, and forgot to set the production status to live. thanks for the tip!

  9. Predrag Drljaca    1236 days ago    #

    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

  10. Darren Mackintosh    1234 days ago    #

    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/

  11. mkavici    1234 days ago    #

    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.

  12. — Darren Mackintosh    1233 days ago    #

    Thank you for the help, it works now. Going to try and shrink the size of the stars

  13. JEL    1230 days ago    #

    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)

  14. mkavici    1230 days ago    #

    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 :)

  15. JEL    1230 days ago    #

    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.

  16. mkavici    1230 days ago    #

    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}

  17. JEL    1230 days ago    #

    Mkavici:
    Yeah! Now it works all right!
    Very, very, very thank you!!! =)

  18. peter    1224 days ago    #

    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/

  19. mkavici    1223 days ago    #

    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;
    }

  20. BryanA.    1222 days ago    #

    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.

  21. Peter    1222 days ago    #

    @ mkavici
    Thanks for your eagle eyes dude!, its always the little things that end up frustrating me.

  22. Simon    1220 days ago    #

    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.

  23. mkavici    1218 days ago    #

    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

  24. — Bob    1213 days ago    #

    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?

  25. mkavici    1211 days ago    #

    Bob,
    yes I will make some changes and add some news functions such as most rated statistics, cookie based control ..

  26. — Loz    1205 days ago    #

    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

  27. Fuls    1203 days ago    #

    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!

  28. mkavici    1202 days ago    #

    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.

  29. — feragnoli    1198 days ago    #

    great plugin!
    Is there now any possibility to sort articles by most rated and least rated?

  30. — feragnoli    1193 days ago    #

    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!

  31. Andrew Swihart    1184 days ago    #

    Could this plugin be adapted to add ratings for files that have been uploaded to textpattern?

  32. — Loz    1180 days ago    #

    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 :)

  33. Rolograaf    1179 days ago    #

    This does not work if Textpattern is not installed in my root-directory?

  34. Rigel    1177 days ago    #

    How to migrate of tcm_rating to css_ratings?

    Thanks!.

  35. mkavici    1176 days ago    #

    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 NULL
    then you can use like this
    <txp:css_rating_bar id=“f80” units=“5” firstvote=“5”/> where f80 stands for the file with id 80

    Loz: 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.

  36. mkavici    1176 days ago    #

    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.

  37. Rolograaf    1172 days ago    #

    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?

  38. — ubo    1158 days ago    #

    congrats on your new job :) do you know approximately when will the next version be released?

  39. Dejan    1127 days ago    #

    Excellent! I’m glad I ran into this plugin, it will come in useful!

  40. Sam    1110 days ago    #

    Using you fantastic plugin over at welovetxp.com, Thank you!

  41. — Tom    1101 days ago    #

    Where do I get the “rating.php” file? It wasn’t in the zip.

    Thanks for the great plugin!

  42. mkavici    1100 days ago    #

    @Tom, it is my mistake there is no such file rating.php ( I used that file when developing the plugin )
    thanks for the correction :)

  43. — Alan    1080 days ago    #

    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

  44. mkavici    1080 days ago    #

    @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.

  45. — Alan    1080 days ago    #

    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?

  46. — Alan    1080 days ago    #

    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

  47. — James    1079 days ago    #

    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?

  48. Werner    998 days ago    #

    Great plugin! Are there any news regarding the “best rated / most rated” feature?

  49. — Raina Gustafson    929 days ago    #

    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?

  50. mkavici    929 days ago    #

    @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.

  51. — Dragan Babić    922 days ago    #

    I am afraid I am having the same problem as Raina above – I can only rate artcles that haven’t been rated yet. If an article has been rated – I am not able to rate it, and I know I haven’t already rated it and that it was someone else, yet it doesn’t let me vote. Also I am not using the id attribute. Any thoughts?

  52. flameo    897 days ago    #

    Hi,
    I’m having the same problem as rolograaf. I have txp installed in subdirectory and can’t make your plugin to work. I used it for rating the file downloads and not articles.
    Can you please take a look here http://www.eurovision-croatia.com/cms/download/?c=DORA-2008
    Thanks!

  53. — Nita    885 days ago    #

    Great plugin! However, when I try to vote, I get taken to a page with a “404 not found” error. Maybe you can help?

  54. matt birkby    839 days ago    #

    hi,

    love the plugin.

    any news on the cookie version – i’d like to use this for our departmental intranet but we are on a shared IP.

    if a cookie version is not on the way, any pointers on stripping out the ip pieces of the code.

    thanks again – its a great plugin.

    matt

  55. MaTaDoR    832 days ago    #

    Really great plugin, thanks.

Görüşünüzü paylaşın

(No HTML, Textile Help only please.)