Custom Rating Fields
By Paul
5/5 based on 3 votes. The median rating is 5.
By Paul
For some purposes, just having a generic website rating isn't enough. You may wish to have several features of each image rated. You can do this by adding custom rating fields.
A custom rating field can be added in the same way as any other new image field, the only difference in the process being that you must give it a name that includes 'rating' in it. For example, 'stylerating'. Add your new field to the voting template or wherever else you wish to put it... the only requirement is that it must be in a form that submits to vote.php in the same way as the current votevalue does. Just copy the existing vote option and change votevalue to stylerating.
In your edit images template, be sure you either make stylerating a hidden field or put it in the admin-only section so that image owners can't cheat.
In your images display templates (and everwhere else that image variables work and you wish to show the ratings), you will need to make note of three separate image variables you can use for data related to your new rating field. Using the example of a field stylerating, you will have {IMAGESTYLERATINGRATING}, {IMAGESTYLERATINGVOTES} and {IMAGESTYLERATINGSTARS}. Note the repetition of the word rating in the first one... this displays the actual average rating based on votes so far. {IMAGESTYLERATINGVOTES} contains the number of votes cast so far.
{IMAGESTYLERATINGSTARS} shows the number of stars graphically. Note that if you wish to show half-star images, you should save these as stars0-5.gif, stars1-5.gif, etc in the images subdirectory of your templates directory (when named this way, they'll automatically be used).
In your voting form, if you wish to let people not fill in that item then put a blank value option above the 1,2,3 etc. For example, <option value="">don't rate this critera</option>
To make showing/editing of individual votes work for custom rating fields, pass &field=ratingfieldname at the end of the normal show votes url.
To do custom ratings for members, use memid=1 in place of id={LINKID} in your form.
A custom rating field can be added in the same way as any other new image field, the only difference in the process being that you must give it a name that includes 'rating' in it. For example, 'stylerating'. Add your new field to the voting template or wherever else you wish to put it... the only requirement is that it must be in a form that submits to vote.php in the same way as the current votevalue does. Just copy the existing vote option and change votevalue to stylerating.
In your edit images template, be sure you either make stylerating a hidden field or put it in the admin-only section so that image owners can't cheat.
In your images display templates (and everwhere else that image variables work and you wish to show the ratings), you will need to make note of three separate image variables you can use for data related to your new rating field. Using the example of a field stylerating, you will have {IMAGESTYLERATINGRATING}, {IMAGESTYLERATINGVOTES} and {IMAGESTYLERATINGSTARS}. Note the repetition of the word rating in the first one... this displays the actual average rating based on votes so far. {IMAGESTYLERATINGVOTES} contains the number of votes cast so far.
{IMAGESTYLERATINGSTARS} shows the number of stars graphically. Note that if you wish to show half-star images, you should save these as stars0-5.gif, stars1-5.gif, etc in the images subdirectory of your templates directory (when named this way, they'll automatically be used).
In your voting form, if you wish to let people not fill in that item then put a blank value option above the 1,2,3 etc. For example, <option value="">don't rate this critera</option>
To make showing/editing of individual votes work for custom rating fields, pass &field=ratingfieldname at the end of the normal show votes url.
To do custom ratings for members, use memid=1 in place of id={LINKID} in your form.
Rating:
5/5 based on 3 votes. The median rating is 5.
Submitted: 09/25/03 (Edited 01/22/07)
Description: Letting people vote on more specific details.
Views:
1710 views. Averaging 1 per day.
In the most recent 30 day period, there've been 3 views.

Print
E-Mail