Content last modified Monday 6 March 2017
hop to #bottom
Categories:
Author:
Current version:
orphaned: Download doesn't work with txp 4.06, author site links outdated
About It:
Get it:
Rate it:
  • Helpful?
  • 3 Yes
  • 0 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

tcm_rating

Allows a rating system.

Features

  • Use images for ratings
  • IP limiting
  • Unlimited rating range

Download:

main download
tcm_ratingcount

Installation:

  • Upload rating_sql.php and rating.php to your Textpattern directory.
  • Go to rating_sql.php
  • Delete rating_sql.php
  • Install tcm_ratinginput and tcm_ratingoutput

Options:

tcm_ratinginput

  • range

tcm_ratingoutput

  • type
    • text (returns the average rating)
    • stars (outputs on/off images to represent the rating)
  • img – the “on” image, the colored-in star
  • offimg – the “off” image, the light star
  • anchor – add an anchor to the rating output

Code examples:
<txp:tcm_ratingoutput type="stars" img="/3/textpattern/graphics/on.gif" offimg="/3/textpattern/graphics/off.gif" anchor="true" />
<txp:tcm_ratinginput range="5" />
<txp:tcm_ratingcount />

Modifications:

Paul Armstrong came up with some nice changes that include auto-submitting and only allowing one vote per article per IP (I’m not sure about that part, considering dynamic IP and ISPs, you might mistakenly block someone else, and a delay is enough to stop flooding)

Article Request Count:

Archived [?]: Download doesn't work with txp 4.06, author site links outdated.

Initially released:
Aug 30, 2004
Posted here:
26 Mar 2005
Article modified:
18 Jun 2008

If there is a comment form at the Information URL, you may want to leave your comments/questions there or at the Forum thread for quicker feedback. Otherwise, comment away:

Your comment will NOT be submitted until you click the 'Submit' button on the next pageload.

Commented (11)

It does not work correctly in Textpattern 4.02.
The database reads correctly, but the output on the webpage is always 0.
Fatal error: Call to undefined function: getmicrotime() in textpattern/lib/txplib_db.php on line 55

I am using txp 4.0.3
For whoever’s looking for this, the dev site’s at http://www.workingidea.com/lab/tcmrating.
Timofej:

If you get 0 instead of average rating you should do the following.
Look through the source of tcm_ratingoutput plugin and find this chunk of code:
foreach($ratings as $value) {$total += value [ 0 ];}
Replace it with the following:
foreach($ratings as $value) {$total += $value[‘rating’];}
This should fix the problem.

Timofej:

As far as an error with getmicrotime() is concerned…
I suppose it all depends on the version of Textpattern. Anyway…
I currently use 4.0.5 and at first I got this error too.
getmicrotime() is defined in txplib_misc.php
So you just should add this line include ‘lib/txplib_misc.php’; anywhere before include ‘lib/txplib_db.php’; in file ratings.php

SmaLL:

worked very nice!!
with 4.0.6 too

sanks to author!!!
and to Timofej for changes

Ratings Were Not Installed

4.0.6

fantasmo:

Hello I get the error messages
_Tag error: <txp:tcm_ratingoutput type=“stars” img=”/3/textpattern/graphics/on.gif” offimg=”/3/textpattern/graphics/off.gif” anchor=“true” /> -> Textpattern Warning: Table ‘textpattern.sw_txp_tcm_ratings’ doesn’t exist
select rating from sw_txp_tcm_ratings as txp_tcm_ratings where parentid = 2 on line 85

Tag error: <txp:tcm_ratinginput range=“5” /> -> Textpattern Warning: Table ‘textpattern.sw_txp_tcm_ratings’ doesn’t exist
select posted from sw_txp_tcm_ratings as txp_tcm_ratings where ip = ‘BookRix-5-PC’ AND parentid = ‘2’ ORDER BY posted DESC on line 85

Tag error: <txp:tcm_ratingcount /> -> Textpattern Warning: tag does not exist on line 1120

Tag error: <txp:tcm_ratingoutput type=“stars” img=”/3/textpattern/graphics/on.gif” offimg=”/3/textpattern/graphics/off.gif” anchor=“true” /> -> Textpattern Warning: Table ‘textpattern.sw_txp_tcm_ratings’ doesn’t exist
select rating from sw_txp_tcm_ratings as txp_tcm_ratings where parentid = 1 on line 85

Tag error: <txp:tcm_ratinginput range=“5” /> -> Textpattern Warning: Table ‘textpattern.sw_txp_tcm_ratings’ doesn’t exist
select posted from sw_txp_tcm_ratings as txp_tcm_ratings where ip = ‘BookRix-5-PC’ AND parentid = ‘1’ ORDER BY posted DESC on line 85

Tag error: <txp:tcm_ratingcount /> -> Textpattern Warning: tag does not exist on line 1120_

I guess it is because I use “sw_” as a table prefix for my TXP installation. Can please somebody tell me, what I should write into the plugins php code, to make it also work with my table prefix?

Thank you :-)

I think that in your case the problem is that database tables were not created. You should check with phpMyAdmin or similar if there is in your Textpattern’s database a table called sw_txp_tcm_ratings.

fantasmo:

@Petri
Thank you for your help.
I checked that…it seems like, there is something wrong with the ratings-sql.php
I googled how to create a table in phpMyAdmin manually, with the fieldnames given in the ratings-sql.php.
That work fine…now I have all my tables and the rating work:-).

Filip Hanker:

the plugin don´t work in Textpattern 4. Here is a workaround: edit the plugin tcm_ratingoutput .

Change

foreach($ratings as $value) { $total += $value0; }

to

foreach($ratings as $value) { $total += $value[rating]; }

Subscribe to this article's comments RSS feed. [ ? ]   View Recent Comments across the site.

Would you care to write a comment or visit the forum discussion?

You know you want to visit the Archives.

Browse

Categories


Articles

There are also tag clouds, 'cause those are fun.
Published with Textpattern