rating type in form fields. The result of the rating is captured as an integer, and displayed as a line of stars. For example,
Install the contrib into your TWiki. You can immediately use the rating type in your forms. Rating values are stored as integers.
To use it in a TWiki form, use the type rating, with the optional modified +small for small stars. The size field dictates how wide the rating is e.g. 5 means a 5 star range. The value field specifies the initial value. For example, the form definition:
| *Name* | *Type* | *Size* | *Values* | | Supplier | text | 40 | | | Quality | rating+small | 10 | 5 | | Order Date | date | | |looks like this when it is edited:
configure interface (Go to Plugins->Find More Extensions) .zip or .tgz archives
perl <module>_installer )
configure and enable the module, if it is a plugin.
,v files in your existing install (take care not to lock the files when you check in)
TWiki::Contrib::RatingContrib::renderRating($name, $size, $small, $value, $input_attrs) -> $html
where $name is the name you want to give to the input element that will get the rating value
$size is the total width of the rating bar, typically 5 or 10
$small is a boolean; if true, use small (10px) stars in place of the default (25px) stars
$value is the current value of the rating. This may be a floating-point value, but should be in the range 0..$size
$input_attrs is a hash that contains additional attributes to be assigned to the input element used to capture the rating value. Typically the only attribute callers will need to use is onchange, which should be set to a callback that will be invoked when the value in the input is changed. If you pass undef for this parameter, then the line of stars will be "read only".
my $html =
CGI::form({action="some url", method=>"post"},
TWiki::Contrib::RatingContrib::renderRating('rating', 5, 0, 0, {})
.CGI::submit("OK"));
Say instead that we want to generate an alert when a line of stars has its
value changed:
$html = TWiki::Contrib::RatingContrib::renderRating('rating', 5, 0, 0,
{onchange=>'javascript: alert("Rated")'})
Of course, when you use the onchange event, you don't need a form. This model
is good if you want (for example) to update values using a REST handler.
| Contrib Author(s): | Crawford Currie http://c-dot.co.uk |
| Copyright: | © 2007 C-Dot Consultants |
| License: | GPL (Gnu General Public License) |
| Contrib Version: | 17384 (12 Dec 2008) |
| Change History: | |
| 27 Jun 2006: | First version |
| Dependencies: | None |
| Contrib Home: | http://twiki.org/cgi-bin/view/Plugins/RatingContrib |
| Feedback: | http://twiki.org/cgi-bin/view/Plugins/RatingContribDev |
| Appraisal: | http://twiki.org/cgi-bin/view/Plugins/RatingContribAppraisal |
| I | Attachment | Action | Size | Date | Who | Comment |
|---|---|---|---|---|---|---|
| |
edit_example.gif | manage | 7.6 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
example_stars.gif | manage | 1.3 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
ie_pick_star.gif | manage | 0.4 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
ie_pick_star_small.gif | manage | 0.2 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
ie_star.gif | manage | 2.0 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
ie_star_small.gif | manage | 0.4 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
leftbar.gif | manage | 0.2 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
mainbar.gif | manage | 0.1 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
pick_star.gif | manage | 0.5 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
pick_star_small.gif | manage | 0.3 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
rating.css | manage | 1.6 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
rating.js | manage | 0.3 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
rightbar.gif | manage | 0.2 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
star.gif | manage | 2.6 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
star_small.gif | manage | 0.6 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |
| |
stars.svg | manage | 12.4 K | 2008-12-12 - 10:26 | TWikiAdminUser | Saved by install script |

| Copyright 2011 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu |
WISEST Helping Women Faculty Advance Funded by NSF | | |