Last updated August 23, 2010. Created by davedg629 on May 8, 2009.
Edited by sivarani, clemens.tolboom, wonder95, martinjbaker. Log in to edit this page.
Tutorial Objective:
Create a simple rating/review system with a Drupal 6 installation and the latest stable versions of the following modules:
This tutorial was written based on testing performed in the following environment:
- Windows Vista Home Edition
- Apache 2.2.8, PHP 5.2.6, MySQL 5.0.51a
- Drupal 6.11
- CCK 6.x-2.2
- Fivestar 6.x-1.15
- Voting API 6.x-2.0-rc2
This tutorial will use two content types created using CCK - Product and Review.
Warning: Each user is allowed to vote though Reviews on each Product just once. This is by design of the Fivestar module. The vote is stored as a Product vote not a Review vote.
Product is the target node type, or in other words, the node type that is being reviewed by users. Users can submit reviews of Product's using the "Review" node type.
The "Review" node type will contain the Fivestar CCK fields that users will use to rate the Product nodes. A multi-axis review system will be demonstrated. The multi-axis review system will consist of reviews that allows users rate a Product in more than one category (e.g. Reliability and Value instead of a single Overall Rating).
Step 1: Create the Product node type using CCK and create a Product
- Create a new node type called "Product".
- Important: Check the "Enable fivestar rating" box under the "Fivestar ratings" fieldset.
This is important because votes made by the Review content type will not be calculated unless this box is checked. - Select "Hidden" under "Teaser Display" and "Full node display".
This will hide the rating widget on the Product nodes (we don't want the widget on the product nodes, we want it on the Review nodes). - Save this content type
- Create a Product node titled "Product A". Note the URL of this node as you will need to come back to it later.
Step 2: Create the Review node type with multiple rating fields using CCK and create a Review node
- Create a new node type called "Review".
- Save the node type
- Select "Manage Fields" for "Review" from the list of content types
- Add a node reference field
- Set the label to "Select the product you wish to review"
- Set field name to "product_reference".
- Select "Node reference" as the field type
- Save the field
- Make the field a required field
- Check the "Product" node type under "Content types that can be referenced".
- Save the field
- Add a Fivestar rating field
- Set the label "Reliablity Rating"
- Set field name "reliability".
- Select "Fivestar rating" as the field type
- Save the field
- Make the field a required field
- Under "Voting target" select the node reference field "field_product_reference". No need for php code.
- Under voting axis, enter "reliability".
- Save the field settings.
- Add a second Fivestar rating field
- Set label to "Value Rating"
- Set field name "value".
- Use the same field settings as the "Reliability Rating" field
- Under voting axis, enter "value".
- Save the field settings.
Now you can create a Review, enter a title, enter body text (optional), give it a rating, and select "Product A" under "Select the product you wish to review". Submit the review.
Step 3: Create custom node template file
Go to your theme folder. Copy node.tpl.php and rename it node-product.tpl.php. Insert the following code in the template file to display the average of the rating:
<?php
$reliability_rating = votingapi_select_results(array('content_id' => $node->nid, 'tag' =>'reliability', 'function' => 'average'));
print '<div><strong>Reliability Rating:</strong>';
print theme('fivestar_static', $reliability_rating[0]['value'], '5');
print '</div>';
$value_rating = votingapi_select_results(array('content_id' => $node->nid, 'tag' =>'value', 'function' => 'average'));
print '<div><strong>Value Rating:</strong>';
print theme('fivestar_static', $value_rating[0]['value'], '5');
print '</div>';
?>The position of this code in the template file will determine where the rating widget(s) is/are displayed on the Product node pages. See Creating and Contributing a Fivestar Widget Set for creating custom fivestar widgets
After you have inserted the display code into node-product.tpl.php, visit the Product A node. You should now see the rating widget(s). In order for the widget to display an average of ratings, you must submit multiple Reviews. By design, a second rating by a user will overwrite the initial rating that user submitted. In other words, you must submit Reviews by at least two different users to see an average calculated on the Product node pages. After you submit multiple Reviews, you can verify that the average is being calculated and displayed.
After this review system has been built, the display of these reviews using Views is the common next step. This second part of this tutorial outlines a simple procedure for displaying the results of each rating axis for each node that is being rated using the system outlined above.
Once the review system is in place, make sure you have at least 1 "Product" node (call it "Product A") and 2 "Review" nodes (call them Review 1 and Review 2) created by 2 different users that rate the "Product A" node.
Step 4: Build a view that displays all "Product" nodes and the average of each rating given to each "Product" node. Sort views by highest rating in different categories.
- Go to admin/build/views and create a new view.
- Give it a View name of "Products" and a View type of "Node".
- Add a Page display and make the title of the page "Products and Product Ratings".
- Make the Style of the page a "Table"
- Make the Path of the page "products".
- Add a field of type "Node: Title".
- Add a filter of type "Node: Type"
- Select "Is one of"
- Check the node type "Product".
- Add a Relationship to the view of the type "Node: Voting results".
- In the previously mentioned tutorial, the axes that were used were "reliability" and "value". Staying consistent, give the relationship a label of "Reliability Results".
- Make the Value type "Percent",
- Select the Vote tag "reliability",
- Select Aggregation function "Average".
- Add a second Relationship of type "Node: Voting results"
- Label it "Value Results"
- Make the Value type "Percent"
- Vote tag "value"
- Aggregation function "Average".
- Add a field of type "Voting API results: Value".
- Make the Appearance "Fivestar Stars (display only)
- Select the Relationship "Reliability Results"
- Set label" "Average Reliability Rating".
- Add another field of the type "Voting API results: Value".
- Make the Appearance "Fivestar Stars (display only)
- Set the Relationship "Value Results"
- Set the Label "Average Value Rating".
You should now have a view that displays the Product name and the aggregate averages for each rating axis (Reliability and Value). Now a sort can be added to this view. Add a Sort Criteria of type "Voting API Results: Value". Make the Relationship "Reliability Rating" and sort "Descending" to go from highest values to lowest values. This will sort the Products from highest "Reliability Rating" to lowest "Reliability Rating". This view can then be cloned and edited so that the products are sorted by different rating axes (sort by Value rating for instance).
Comments
Making this work...
Hi there,
This is exactly what I am looking for. All of the functionality that you describe meets all of my needs. However, I simply cannot make it work. I am a complete newbie to Drupal and as such I have tried really hard to follow all of the instructions to the letter, but something somewhere has gone wrong.
I can see the Fivestar 'stars' on the Product A node, but when my mouse rolls over them, nothing happens! JavaScript is enabled and I am able to vote on 'stars' if I simply enable the Fivestar module in comments from the Product content type 'edit' area.
I'm just stumped!
Sorry, and I hope that someone might be able to help me out with this one.
Thanks.
www.pictureandword.co.uk
What you are seeing on the
What you are seeing on the Product A node is the aggregation of all the other Reviews, not a "rateable" widget, but a ratings display widget. What this tutorial leaves out is how to place a link on the Product A node that takes you to the "review node" with the node-reference already filled out. Either that or I just dont understand it..
modal popup?
That you have to submit a review via a different node rather than just using the widget you see there in front of you, and possibly have to use a select dropdown or maybe an auto-complete to choose the node to review, leads me to wonder if anybody has used a ctools modal dialog to create the review node. That way you could prepopulate or something and never really leave the page you are voting on.
A lot of module do that, for
A lot of module do that, for example: node reference url
http://mustardseedmedia.com/podcast/episode37
Same here
Yep, me too. I have reproduced this situation. I am not sure how exactly to solve it, but it had to do with permissions. I did fix it.
Prepopulate
You can do that with the prepopulate module or if you plan to use Form API just send a get parameter along the way. If you did not understand the last part, then go for prepopulate :)
http://drupal.org/project/prepopulate
Brilliant tutorial, worked
Brilliant tutorial, worked fine using D6.13 and VotingAPI 6.x-2.x-dev and Fivestar 6.x-1.18.
Hopefully, with some theming and something like a javscript popup to create a review on a node without navigating away will be great.
Thanks but I cant get views to work.
I learned a lot here but for whatever reason the view is empty whenever I add the relationship as above.
Any ideas??
this work only if review is published
how to show the voting result with unpublished review? and how to show the numer of voters?
would like to use this too
I am trying to make this work also, but the tutorial assumes that I know more about Drupal than I do.
Create a new content type called "Review" and save it. Then under the [Manage Fields] tab, add a node reference field ...
Instead of:
Create a new node type called "Review". Save the node and add a node reference field with the label "Select the product you wish to review" and field name "product_reference". (how did you complete the instructions in the first sentence WITHOUT saving it?)
"This tutorial was written based on testing performed in the following environment:"
If any of the tutorial discusses views, installing it should be a pre-requisite, or at least mentioned.
"Copy node.tpl.php and rename it node-product.tpl.php"
Might be re-written "Copy node.tpl.php to node-product.tpl.php".
Hey guys I am trying
Hey guys I am trying something similar as well, but this tutorial doesn't quite allow us to do what I think we all want. I am trying to create a game rater where users rate a game based on graphics, sound, gameplay, and difficulty. I want them to be able to vote for all of these things right in the node with the game info and picture. How can I do this?
Hi, I'm using fivestar
Hi, I'm using fivestar comments rating for rating comments and I'd like to have average voting widget calculated from all comments ratings in node.tpl.php, is it possible?
search for video tutorial.
search for video tutorial. one of them had this info
template part works. views
template part works. views all good until creation of relationship - it immediatly returns error
OR .value_type_other. "overall" is tag or axis.
sorry. update to latest
sorry. update to latest version helped.
set the widget to display current average in text
How to set the widget to display current average in text (example:Average: 2.5 (20 votes)) below the stars? I guess node-product.tpl.php should be edited but I don't know how.
How to add vote up/down?
I want to use vote up/down along with fivestar.
I want to show "x% of users recommend this" on product page.
How can I do that?
up down voting
Try Following drupal modules for up down voting
vote_up_down
updown
There is a module called flag this I guess you can use to make any node favourite node(you can use favourite node in context of recommendation ).
you can achieve what you are looking for by using any 2 of above mentioned 3 modules. just do a bit of RnD on those.
They don't
I tried them.
They won't integrate with node reference. They can be used to vote a node directly, but can't be used to vote on referenced node.
Meanwhile, I also thought of using 2 star "fivestar". But I can't find a way to show different images on different stars. i.e. 1st one = thumbs up, 2nd =thumbs down.
Up down and node referral
Hi prabhakarsun
I m not clear about your complete requirements , just a try...
Im assuming that there is always only one review node corresponding to a product node
pn1 referenced by rn1
pn2 referenced by rn2
...
Apply vote up down on review node.
Download http://drupal.org/project/referral module : it will provide a read only cck field, Add it to product content type.
Product $node object will contain id of referral node (that will be review type node).
Load referral node(review node) which will contain all data of review.
Print the up down score of review node, which is actually for the product node.
And while giving fivestar rating to review node user will be able to up/down vote for review node.
You just need to put efforts on how to use referral module...
Note : once you apply node referral cck field to product node you must edit and save corresponding review node so that this module saves referral value.
Hope it helps
Thanks for your advice, but
I am trying to create a user review site.
Here are full details:
Content type 1: Products
Content type 2: Reviews
Registered Users can review products by referencing "Product" nodes.
What I want to have is a "Would you recommend? [ Yes/No ]" field in Review. Then I need to show "x% of users recommend it" on product page.
So obviously, I will be having multiple review nodes per product node.
NOt showing up..
i applied the php code to node-product.tpl.php and no widget is appearing on the node display. when i use devel to check, it shows that it is still using the node.tpl.php file with candidate node-product.tpl.php < node.tpl.php, what am i doing wrong? thanks in advance
Displaying average of all votes (sum up the multi-axis)
This is one great documentation, with the help I have managed to come as far as setting up the review system of 3 axis. I was able to configure Views to display the average of votes on a view page.
See screenshot: http://dropbox.akandatang.info/multi-axis.png
But now I'm faced with the new challenge: to display the average of overall votes (by summing up all 3 axis, then average.)
For example, given a voting scores like below:
First axis: Quality - 60%
Second axis: Value - 50%
Third axis: Reliability - 90%
Therefore the average of the above = (60+50+90)/3 = 66.67%
I was able to show the average on node page by using this code:
$overall_score = (($quality_rating[0]['value'])+($value_rating[0]['value'])+($reliability_rating[0]['value']))/3;print theme('fivestar_static', $overall_score, '5');
But what I need now is to add a column to the views page and display the average. What should I do to achieve that?
You may think about of using
You may think about of using a cck computed field, http://drupal.org/project/computed_field
How did you do that
Displaying average of all votes (sum up the multi-axis)
deanloh - November 9, 2009 - 08:16
Can you please tell how did you do that?
Anyone know how to display the reviews on the product page?
Thank you. This tutorial is great.
Declare the (5*)field in tpl
I will look into but can't you declare a cck field in the tpl file and will show up for views?
which permissions are needed to display the node selection
Hi,
I followed this nice tutorial, and it works great. As long as i'm logged in as an admin, i can create reviews. When I'm a reviewer (seperate role), I can create a review, but the product drop down is missing. It is there when I'm an administrator (all privileges).
So i'm trying to figure out where I need to add an extra permission so that the product selection will show up for my reviewers.
At least, if this is a permissions issue. Ideas are most welcome!
thanks.
User "edit" field in cck permission
Hi,
I ran into that as well.
You have to set the permissions for your users to be able to "edit value field" or "edit reliability field"... whatever you set your cck field name to. Also, allow them to use fivestar and voting...
Sza
No average showing
Hi all,
Thanks for this tutorial. Saved my day.
Almost there but got snagged though.
On my product page - it shows the five star widget fine, but does not reflect any results! I have two reviews, from two separate users and still nothing...
any thoughts?
Sza
Figured this one out
I, when doing the tutorial, did not use the same value names to review (value and reliability) and instead used two more relative to my website.
If you did the same, when inserting the code above into your node template file, make sure you change all the variables from value and reliability to reflect your cck fields.
Nice! =)
Sza
Average voting with same user
From the tutorial:
"Once the review system is in place, make sure you have at least 1 "Product" node (call it "Product A") and 2 "Review" nodes (call them Review 1 and Review 2) created by 2 different users that rate the "Product A" node."
Is there a way to allow the average of reviews from each "product" node from the same user, rather than different users?
My use case is set up a bit differently. For me, each "product" is actually a company that produces multiple products. That makes the review node a review for each product, the focus on my site being comparing different companies. Each company's rating is the average of all its reviewed products.
You can see why it would then make sense for multiple "review" nodes to come from the same user, because they can be of different items the company produces.
Also, I'm very new to Drupal. Any help with this issue, or suggestions of a better way to set this up would be appreciated. Thanks!
-Chris
Not working...SQL Error
I followed the tutorial, but I get an SQL error when I am setting up the 'Relationships' in the View creation step.
user warning: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near 'Functionality_average ON node.nid = votingapi_cache_node_percent_Site Functional' at line 4 query:
SELECT node.nid AS nid, node.title AS node_title
FROM
node node
INNER JOIN
votingapi_cache votingapi_cache_node_percent_Site Functionality_average
ON node.nid = votingapi_cache_node_percent_Site Functionality_average.content_id
AND (votingapi_cache_node_percent_Site Functionality_average.content_type = 'node'
AND votingapi_cache_node_percent_Site Functionality_average.value_type = 'percent'
AND votingapi_cache_node_percent_Site Functionality_average.tag = 'Site Functionality'
AND votingapi_cache_node_percent_Site Functionality_average.function = 'average')
Help appreciated. Thanks.
TIW
As the documentation said, a
As the documentation said, a new submitted rating will override previous rating of a user (the same user), then problem occur.
A user can submitted unlimited of review of a product, then there will come into a situation, where there may have number of review nodes of a product from a user.
And 2nd scenario is , how about rating from anonymous user ? identify as same user ??
Problem with Views + Fivestars
I want to view the rating of nodes by sum of given votes. In "Add relationships" i choused "Vote results"
Value type: No filtering
Vote tag: No filtering
Aggregation function: Total score
And here is the query:
SELECT nid,
votingapi_cache_node_sum.value AS votingapi_cache_node_sum_value
FROM node node
LEFT JOIN votingapi_cache votingapi_cache_node_sum ON node.nid = votingapi_cache_node_sum.content_id AND (votingapi_cache_node_sum.content_type = 'node' AND votingapi_cache_node_sum.function = 'sum')
ORDER BY votingapi_cache_node_sum_value DESC
But it does not work (((
There is no row with function = sum for any nodes in the table votingapi_cache
It may be the bug of this module (fivestars) or i'm doing something wrong (((
plz, if somebody do something like this, help me ((
ps: sorry for my english )))
Is votingapi_vote supposed to be updated for this to work??
I can't get the average to display...
From what I see in my issue, no entries are being made into the votingapi_vote table. Is this correct?
1. The field types are all correct
2. All entries in the actual content type table are all updated correctly
3. No updates to votingapi_vote
4. Result: stars with no rating
Am I missing something??
http://themysterysfinalpage.co.cc
I got it almost working the
I got it almost working the way I want. Thanks for this great tutorial.
But i would like users to be able to vote on the product page itself.
So instead of
$reliability_rating = votingapi_select_results(array('content_id' => $node->nid, 'tag' =>'reliability', 'function' => 'average'));print theme('fivestar_static', $reliability_rating[0]['value'], '5');
I tried:
print theme('fivestar_widget', $reliability_rating[0]['value'], '5');This shows only empty space.
and when trying:
print theme('fivestar_preview_widget', $reliability_rating[0]['value'], '5');It's shows the fivestar widget but votes are not saved. (It doesn't say that the vote is saved, unlike the normal widget).
Does anybody know if it's possible to vote on the products page?
Well, it works, but is there a way to...
It works fine, but I would like to remove the "Select the product you wish to review" step, and add a button on each product with 'Review the product' title, meaning that when clicking, I will automatically review the product.
Very much like they did on http://drupalmodules.com have, for example on this page: http://drupalmodules.com/module/fivestar
yes, either in page or pass args to the form
I used FormBlock module, enabled form-in-block for review types and placed it below all pages of the node type i want to vote on, then redirect back to the node after form submission.
I have done this on a site here : http://www.profwriting.com/manuscripts/tristans-adventures-cave
when you are logged in there is a field-set below the node which expends to show and review add form, and the node reference is field is filled using url arguments then can can be hidden.
OR if you want to link off the page make a link to /node/add/review and place product node id on the end such as /node/add/review/66 and use PHP code in the default settings in your node_reference field in CCK for the product node type, such as
return array(0 => array('nid' => arg(3)),
);
in the case above.
I've attached a screen grab so you can see the form when you are logged, it is nice having it all on one page, the 'review now' button at the top is just an anchor.
http://8bitplateau.net/tmp/5star_screengrab.png
also I did have to theme the averaging myself as it didn't work first time.
Hope that helps :)
j8p
[excite an electron ?]
I've tried to add return
I've tried to add
return array(0 => array('nid' => arg(3)),
);
however when I tried to save it, I've got an error:
"The PHP code for 'default value' returned Array ( [0] => Array ( [nid] => movie-review ) ) , which is invalid."
I figured that this is because the page where I edit it is:
admin/content/node-type/movie-review/fields/field_movie_reference
Naturally, the number 3 argument is 'movie-review'. How do I create a check to see that the 3rd argument is actually a valid one?
I tried something like:
$valid_choice = arg(3);
if is_int($valid_choice) == 0
$valid_choice = '';
return array(
0 => array('nid' => arg(3)),
);
But I am a PHP newb and don't really know how to do it.
Hi, It is strange that the
Hi,
It is strange that the check is only needed because it otherwise goes wrong on the contenttype node reference page...
But this is working for me!!
if (is_numeric(arg(1))) {return array( 0 => array('nid' => arg(1)));
} else {
return array( 0 => array('nid'));
}
Exactly what I want but...
Hi digitisation,
Your site is exactly what I'm looking to get, only with reviews about games. I've set my two types of content (games and reviews). However I can't get my games node page to show all reviews referencing to it. Do I need to setup a special view for that? or do I need to add some code to the node-games.php?
I'm a real drupal newbie so maybe the answer is completely obvious. Still thanks a lot for your help!
hey, i like what you did on
hey, i like what you did on your site. that's exactly what my team is trying to come up with. just curious if you were able to prevent users from posting multi-reviews on a single node?
[SOLVED] template problem
[SOLVED] Hi,
It says: "After you have inserted the display code into node-product.tpl.php, visit the Product A node. You should now see the rating widget(s)."
However, I don't see the rating widget on the product page. What am I doing wrong?
Great guide, but I've got one
Great guide, but I've got one problem I can't figure out...
I followed the 4 steps in the guide, but I used 10 stars to rate with, instead of the normal 5, but when I completed the 4th step (Step 4: Build a view that displays all "Product" nodes and the average of each rating given to each "Product" node. Sort views by highest rating in different categories.) it looked strange when it had to display the 10 rating-stars in 'Views'... So I changed it back to 5 stars...
After changing back to 5 stars, 'Views' still displayed 10 stars..! So I deleted the 'View', and made a new by following the guide, but IT STILL DISPLAYS 10 STARS IN THE 'VIEW' ???? How come ??? I tried running a cron-job and I tried refreshing the page, but nothing changes...
Please help...
Thanks,
Marc.
Hi i was wondering how one
Hi i was wondering how one would go about implementing this for doing Film reviews? As far as i can make out site admin would have to create a product node for each film and that would be a hell of a lot of films to cover. alternatively reviewers could add their film first and then add a review. am i missing something here? Its all to do with the node referance isnt it?
http://onlinebanter.com
Voting API
(Add a second Relationship of type "Node: Voting results"). I cannot find the Nodetype "Voting API". How can I solve this?
This is how I achieved multi-axis with fivestar in 3 easy steps
In this case we will be using 3 axis("vote","taste","freshness").
The following steps shows you how to configure the second & the 3rd fivestar custom widgets, assuming you will be using the widget added by the fivestar module as your first voting axis.
Step 1. Enable fivestar voting for the content type.Please check fivestar README.txt for detailed instructions.
Step 2. Implement a custom function responsible for the settings of your custom fivestar widgets.
/*Params:
* content_id,nid: Id of the node you want to vote on.
*$content_type: will always be 'node' since we voting on nodes not comments.
* $tag:
*/
function YOUR_MODULE_NAME_vote_settings($content_id,$content_type,$tag){
global $user;
if ($content_type == 'node') {
if (is_numeric($content_id)) {
$node = node_load($content_id);
}
else {
return array();
}
}
// You might want to check fivestar for other possible values for $star_display and $text_dispaly.
$star_display = variable_get('fivestar_style_'. $node->type, 'average');
$text_display = variable_get('fivestar_text_'. $node->type, 'dual');
//get current votes for the given tag.
if ($star_display == 'average' && ($text_display == 'average' || $text_display == 'none')) {
// Save a query and don't retrieve the user vote unnecessarily.
$votes = fivestar_get_votes($content_type, $content_id, $tag, 0);
}
else {
$votes = fivestar_get_votes($content_type, $content_id,$tag);
}
$values = array(
'user' => isset($votes['user']['value']) ? $votes['user']['value'] : 0,
'average' => isset($votes['average']['value']) ? $votes['average']['value'] : 0,
'count' => isset($votes['count']['value']) ? $votes['count']['value'] : 0,
);
$feedback_enable = variable_get('fivestar_feedback_'. $node->type, 1);
$labels_enable = variable_get('fivestar_labels_enable_'. $node->type, 1);
// now unique settings per tag/axis
switch(tag){
case'taste':
$title = t("Rate the taste of our fruit juices ");
$text_display = "dual";
$labels = array("Ok, I guess","Can be better", "Ohhh","Tickle my taste buds");
$stars = 4;
break;
case'freshness':
$title = t("Freshness");
$text_display = "dual";
$labels = array("vote1","vote2","vote3","vote4");
$stars = 4;
break;
}
$settings = array(
'stars' => $stars,
'allow_clear' => variable_get('fivestar_unvote_'. $node->type, FALSE),
'style' => $star_display,
'text' => $text_display,
'content_type' => $content_type,
'content_id' => $content_id,
'tag' => $tag,
'autosubmit' => TRUE,
'title' => $title,
'feedback_enable' => $feedback_enable,
'labels_enable' => $labels_enable,
'labels' => $labels,
);
$form = drupal_get_form('fivestar_custom_widget', $values, $settings);
$form = str_replace(array('<form', '</form>'), array('<div', '</div>'), $form);
$form = preg_replace('/( method=".*?")|( action=".*?")|(<input.*?name="(form_token|form_id|destination|form_build_id)".*?\/>)/', '', $form);
return $form;
}
Step 3: Implement the nodeapi
function YOUR_MODULE_NAME_nodeapi(&$node, $op, $a3, $a4){
if(($node->type =="YOUR_CONTENT_TYPE") && ($op == "view")){
$content_type = 'node';
$content_id = $node->nid;
$wigdet_vote_freshness = "<div class ='YOUR_MODULE-vote-freshness'>";
$wigdet_vote_freshness .= YOUR_MODULE_vote_settings($content_id,$content_type,"freshness");
$wigdet_vote_freshness .="</div>";
$wigdet_vote_taste = "<div class ='YOUR_MODULE-vote-taste'>";
$wigdet_vote_taste .= YOUR_MODULE_vote_settings($content_id,$content_type,"taste");
$wigdet_vote_taste .="</div>";
if (user_access('rate content') ) {
$node->content['fivestar_custom_taste'] = array(
'#value' => $wigdet_vote_taste,
'#weight' => 50,
);
$node->content['fivestar_custom_freshness'] = array(
'#value' => $wigdet_vote_freshness,
'#weight' => 51,
);
}
}
}
Thats it.
note: i use these classes YOUR_MODULE-vote-freshness and YOUR_MODULE-vote-taste to customise the css styles of my custom fivestar widgets .ie
div.YOUR_MODULE-vote-freshness div.fivestar-widget-static .star span.on {background-image: url(images/fivestar/freshness.png);
}
Drupal 7
Do you have some experience with Drupal 7? I was trying to do the same with Drupal 7, but couldn't manage to do that.
The Stars won't show up in the view, only numerical values
I have finished following this tutorial completely, with everything rating and calculating correctly.
My final problem is that I cannot get the view to display using the fivestar widget. I only get a numerical result. When I change the "Appearance" field from "Default Appearance" to "Fivestar Stars (display only)" it does nothing and I still get the numeric representation.
Any idea why it won't update and save my changes? Everything was going extremely well until this problem.
Hi, I have exactly the same
Hi,
I have exactly the same problem as barry769.
I want to add the following.
When I change the Appearance field from "Default Appearance" to "Fivestar Stars (display only)" and I click on Update it should be changed, but when I get back to the Field it is "Default Appearance" again.
Conclusion, the change in Appearance is not saved somehow I think.
EDIT: May be solution here: http://drupal.org/node/811882#comment-3378334 !
Yes this patch worked for me!
Thanks for going into this.
Greetings, Martijn
How do I display all the
How do I display all the reviews associated to a particular product? So I want to create a 'view' that's a block and put it under each product so that users can see all the other users reviews for this product...
Thanks
FIXED: http://drupal.org/node/928382
Anyone had an issue of
Anyone had an issue of fivestar allowing multiple votes? I followed the instructions here but a user can vote as many times as they want... dont know why!
I'm also facing the same
I'm also facing the same problem. In my case, it shows average rating considering the last vote from each user which is alright but when showing the reviews, it shows all. Do I need to delete all the old reviews on form submit?
--------------------------------------------------
http://one-problem-a-day.blogspot.com/
Additional Info - Displaying in Blocks and Hidden Node Reference
Thank you for the great tutorial. Like some others here, I ran into some things I wanted to add/modify with this set up so I thought I would share the results. Note that I've only been using Drupal for about a month and do not have strong PHP skills, so I lean strongly toward the "find a module for it" side of things.
First, for those wanting to take the "selection list" for the node reference field out of the equation, I recommend http://drupal.org/project/nodereference_url The Node Reference URL Widget allows you to: a) auto-enter the node-reference field from the "product" page into your "review" node creation and make it uneditable b) easily add a link to the "product" page to "create a review".
In addition, I really wanted to display the aggregated (average) axis votes and user reviews in separate blocks. I felt this would give me more control over the layout since the solution above buries the display within the content. Again, being new to Drupal, I struggled to get this working because I was missing one integral piece. Since blocks on a page apparently don't automatically know what node is being displayed in the content (or am I missing something), you have to tell the block view what to do if the argument isn't present, ala this post: http://drupal.org/node/928382
This has allowed me to place the reviews in a block below the product content which will hopefully give me better control over formatting through theme and CSS. I'm still trying to determine a way to place the aggregate averages of votes in the layout without hardcoding PHP in the template layer. I'm aware of the Calculated Field module but, again, I don't have strong skills in PHP so I'm seeking something more point any click.
Any suggestions would be appreciated!
Preventing multiple reviews
I used the above document to create a review system, but now I'd like to prevent users from reviewing the same item multiple times. Any idea on how I could achieve this? I'm a beginner with Drupal, therefore any suggestion will be more than welcome. Thanks in advance.
Path To Enlightenment - A Journey To Overcome Negativity
D7 update
I would be nice to see an update of this for D7 since there is no methodology on this matter at the moment.
Maybe rules?
I am trying to achieve the same, after some research it seems like it can be done using the rules module but I am also a beginner so it's taking me a while to figure it out. If somebody else knows how to do it please share.
Same here.
Same here. How to prevent a user from posting multiple reviews for a single node.
Have you tried this?
I used this module as per the suggestion here and it works for me.
http://drupal.org/node/1075276#comment-4173364
Hope it helps.
TIW
Thanks, tiw! Unique Field
Thanks, tiw! Unique Field Module works well with this tutorial! I made the "node reference" to be the unique field and edited the error msg to jive with my content. I enabled "Check this box to show which nodes match when duplicate values are found:" so reviewing users can go back to their reviews and change/modify their reviews+ratings.
Thanks again.
Can you please tell me how to
Can you please tell me how to display the link to review like: "Write A Review". I watched the tutorial at MustardSeed about Node Reference but I want to make the link be available on different spot on my Review Nodes and not on the $links. Thanks again!
Re:
I don't think I am following your question.
As far as I know, the link appears on the 'product' node. I am currently showing the 'Write a Review' link on the 'Product' node. I haven't tried anything else yet.
TIW
This is a working tutorial
This is a working tutorial for views and regular nodes. Thx! However,
I am using Panels and overwriting node template with Panel Node Template.
The multi axis fivestars widgets, looks like, does not appear within Panel Node Template.
Panel node template gives additional layout flexibility to place multi axis fivestar widgets around the
node layout portions.
Is there any body else experienced the same issue? Is there any solutions ?
Thx
Same tutorial, with Drupal 7.x
Hello,
I've struggled with this tutorial to make it work on drupal 7, and I think I have it now, so here is the thing (assuming you take the same two voting axis) :
Required modules
Step 1: Create the rating axis
Go to Configuration » Fivestar (admin/config/content/fivestar) and add as many axis you like in the "Voting tags section".
Step 2: Create the Product node type using CCK and create a Product
This is important because votes made by the Review content type will not be calculated unless this box is checked.
This will hide the rating widget on the Product nodes (we don't want the widget on the product nodes, we want it on the Review nodes).
Step 3: Create the Review node type with multiple rating fields using CCK and create a Review node
Now you can create a Review, enter a title, enter body text (optional), give it a rating, and select "Product A" under "Select the product you wish to review". Submit the review.
Step 4: Display the reviews on the product page
No need with the use of the Views module for php code, here is the trick :
There you go, it worked for me, but I'm not sure it will work as well for you. I'm interested to know if that worked for you, and if not, maybe we can figure out why and so have a 7.x tutorial working fine ! Any hints, further (and smarter) settings or feedback welcome !
Y.
Hi
I have tried your tutorial and it is not clear. Can you please write it again? if someone can correct/make it more clear it will be very useful for a lot of people. I have tried it myself and it is working half way. there is few thing that need to be clear. like: add five star field, "under "Voting target"... were is that? and add new Contextual filter, check"content: "Select... no such thing...
my hole project is dependent on this thing. Please help me finish it if you can...
Thanks a lot.
Please clarify
I have tested these steps with Drupal 7.8, Fivestar 7.x-2.0-alpha1, Voting API 7.x-2.4, and References 7.x-2.0-beta3.
I am unclear on the following:
Without the last two, these steps can't be followed.
Thanks for any help you can offer.
I'm having problems with step
I'm having problems with step 2.2
The tab for fivestars isn't displayed.
Trouble with the custom Node Template
Hi, I am using Drupal 6.22 and the latest versions of 5 star, Voting API , CCK modules. After embedding the said code in custom node node-product.tpl.php... on the Product page I do see the 5 star widget .. however there are two problems with the widget :
a) It shows no rating whatsoever, all the stars are white (and of course its not possible to rate here)
b) I have submitted multiple user reviews (of different users) yet no average vote is displayed.
In my attempt to trace the issue , I realized that in the code
<?php$reliability_rating = votingapi_select_results(array('content_id' => $node->nid, 'tag' =>'reliability', 'function' => 'average'));
print '<div><strong>Reliability Rating:</strong>';
print theme('fivestar_static', $reliability_rating[0]['value'], '5');
print '</div>';
Even if I remove the first line i.e. one that starts with $reliability_rating , then still I am getting the same result on refreshing the Product A node. So, one thing is for sure that the error lies in that line. Perhaps some changes have happened to the API of late ?
Please help.
Bhambry
I am having the exact same
I am having the exact same issue. Did you figure out a solution?
Problems deleting.
I have something set up very similar but I am having problem if I delete a node with a review... review --> organization. When the review is deleted the vote remains associated with the organization.
Help would be very much appreciated.