SlideShare a Scribd company logo
1 of 3
Download to read offline
Create a simple rating/review system with a Drupal 6 installation and the latest stable versions of the following modules:

•    Fivestar
•    Voting API
•    CCK

This tutorial was written based on testing performed in the following enviroment:

•    Windows Vista Home Edition
•    Apache 2.2.8, PHP 5.2.6, MySQL 5.0.51a
•    Drupal 6.10
•    CCK 6.x-2.2
•    Fivestar 6.x-1.13
•    Voting API 6.x-2.0-rc2

This tutorial will use two content types created using CCK - "Product" and "Review". "Product" is the target node type, or in
other words, the node type that is being reviewed by users. Users can submit reviews of Products'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 single rating
review system and 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).

Single rating review system:
Step 1: Create the Product node type using CCK and create a Product

Go to admin/content/types/add and create a new node type called "Product" (no quotations). IMPORTANT: CHECK THE
"ENABLE FIVESTAR RATING" BOX UNDER THE "FIVESTAR RATINGS" FIELDSET. Votes made by the Review content type
will not be calculated unless this box is checked. Then 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 and 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 a single rating field using CCK and create a Review node

Go back to admin/content/types/add and create a new node type called "Review" (no quotations). Save the node type and then
click "manage fields" for the Review node type. Add a new field with the label "Select the product you wish to review", field
name "product_reference", field type "Node reference", and form element "Select list". Under the global settings, make the field
required and check "Product" under "Content types that can be referenced". Save the field and add another field with the label
"Overall Rating", field name "overall_rating", field type "Fivestar Rating", and form element "Stars". Under Review settings,
uncheck "Allow user to clear value". Under Global Settings, check the "Required" box and under "Voting target", select the
node reference field "field_product_reference". PHP CODE IS NOT NEEDED -- LEAVE BLANK. VOTING AXIS IS NOT
NEEDED FOR SINGLE REVIEW SYSTEM -- LEAVE BLANK. 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
$current_rating = votingapi_select_results(array('content_id' => $node->nid, 'function' =>
'average'));
print '<div><strong>Rating:</strong>';
print theme('fivestar_static', $current_rating[0]['value'], '5'); //this is for 5 stars,
enter 10 (or whatever) instead as appropriate
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.

After you have inserted the display code into node-produt.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 wil 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.

Multi-axis Rating System:
Step 1: Create the Product node type using CCK and create a Product

Go to admin/content/types/add and create a new node type called "Product" (no quotations). IMPORTANT: CHECK THE
"ENABLE FIVESTAR RATING" BOX UNDER THE "FIVESTAR RATINGS" FIELDSET. Votes made by the Review content type
will not be calculated unless this box is checked. Then 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 and 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 (Multi-axis Rating System): Create the Review node type with multiple rating fields using CCK and create a Review node

Go back to admin/content/types/add and create a new node type called "Review" (no quotations). Save the node type and then
click "manage fields" for the Review node type. Add a new field with the label "Select the product you wish to review", field
name "product_reference", field type "Node reference", and form element "Select list". Under the global settings, make the field
required and check "Product" under "Content types that can be referenced". Save the field and add another field with the label
"Reliablity Rating", field name "reliability", field type "Fivestar Rating", and form element "Stars". Under Review settings,
uncheck "Allow user to clear value". Under Global Settings, check the "Required" box and under "Voting target", select the
node reference field "field_product_reference". PHP CODE IS NOT NEEDED -- LEAVE BLANK. Under voting axis, enter
"reliability". Save the field settings. Enter a second rating field with label "Value Rating", field name "value", field type "Fivestar
Rating", and form element "Stars". Use the same field settings as the "Reliability Rating" field, but under voting axis, enter
"value". Save the field settings.

Step 3 (Multi-axis Rating System): 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.

After you have inserted the display code into node-produt.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 wil 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.

Displaying Fivestar Multi-axis Review Ratings with Views 2.x

This tutorial was using Drupal 6.11 and Fivestar 6.x-1.15.

After setting up a mult-axis review system using the above instructions, the next logical step would be to display the results
using a view. Here are the instructions for building such a view.

Step 1: Have a multi-axis review system in place with at least 1 reviewable node and 2 reviews submitted for that node.

Following the previously mentioned tutorial, build a review system consisting of a "Product" node type and "Review" node type.
"Product" is the node type that will be reviewed by the "Review" node type. "Review" node type will allow users to create
reviews of Products and rate the products on multiple axes.

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 2: 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" and make the Path
of the page "products". Add a field of type "Node: Title". Add a filter of type "Node: Type" and select "Is one of" and check the
node type "Product".

Now 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", the Vote tag "reliability", and the Aggregation function "Average". Add a secon Relationship of type "Node: Voting
results" - label it "Value Results", make the Value type "Percent", Vote tage "value", and Aggregation function "Average".

Now add a field of type "Voting API results: Value". Make the Appearance "Fivestar Stars (display only), the Relationship
"Reliability Results" and the Label" "Average Reliability Rating". Add another field of the type "Voting API results: Value". Make
the Appearance "Fivestar Stars (display only), the Relationship "Value Results" and 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).

More Related Content

What's hot

introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basicsRavindra K
 
Visual Studio 2012 Course Blackboard TIC
Visual Studio 2012 Course Blackboard TICVisual Studio 2012 Course Blackboard TIC
Visual Studio 2012 Course Blackboard TICMauricio Correa
 
Apps 11i10 Forms Personalization
Apps 11i10 Forms PersonalizationApps 11i10 Forms Personalization
Apps 11i10 Forms PersonalizationHossam El-Faxe
 
Lab Management with TFS 2010
Lab Management with TFS 2010Lab Management with TFS 2010
Lab Management with TFS 2010Ed Blankenship
 
Lab 2: Creating views at the project level in the web client
Lab 2: Creating views at the project level in the web clientLab 2: Creating views at the project level in the web client
Lab 2: Creating views at the project level in the web clientIBM Rational software
 
Lab 3: Optional: Creating views at the module level (web client)
Lab 3: Optional: Creating views at the module level (web client)Lab 3: Optional: Creating views at the module level (web client)
Lab 3: Optional: Creating views at the module level (web client)IBM Rational software
 
Administrating Req Pro
Administrating Req ProAdministrating Req Pro
Administrating Req ProLeslie Munday
 
Lab 3: Commenting on artifacts and customizing dashboards
Lab 3: Commenting on artifacts and customizing dashboardsLab 3: Commenting on artifacts and customizing dashboards
Lab 3: Commenting on artifacts and customizing dashboardsIBM Rational software
 
Forms personalization
Forms personalizationForms personalization
Forms personalizationRajiv reddy
 
Hands-On Lab Data Mining - SQL Server
Hands-On Lab Data Mining - SQL ServerHands-On Lab Data Mining - SQL Server
Hands-On Lab Data Mining - SQL ServerSerra Laercio
 

What's hot (12)

introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basics
 
Visual Studio 2012 Course Blackboard TIC
Visual Studio 2012 Course Blackboard TICVisual Studio 2012 Course Blackboard TIC
Visual Studio 2012 Course Blackboard TIC
 
Apps 11i10 Forms Personalization
Apps 11i10 Forms PersonalizationApps 11i10 Forms Personalization
Apps 11i10 Forms Personalization
 
Lab Management with TFS 2010
Lab Management with TFS 2010Lab Management with TFS 2010
Lab Management with TFS 2010
 
Lab 2: Creating views at the project level in the web client
Lab 2: Creating views at the project level in the web clientLab 2: Creating views at the project level in the web client
Lab 2: Creating views at the project level in the web client
 
Lab 3: Optional: Creating views at the module level (web client)
Lab 3: Optional: Creating views at the module level (web client)Lab 3: Optional: Creating views at the module level (web client)
Lab 3: Optional: Creating views at the module level (web client)
 
Administrating Req Pro
Administrating Req ProAdministrating Req Pro
Administrating Req Pro
 
Lab 3: Commenting on artifacts and customizing dashboards
Lab 3: Commenting on artifacts and customizing dashboardsLab 3: Commenting on artifacts and customizing dashboards
Lab 3: Commenting on artifacts and customizing dashboards
 
Forms personalization
Forms personalizationForms personalization
Forms personalization
 
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
 
Oaf personaliztion examples
Oaf personaliztion examplesOaf personaliztion examples
Oaf personaliztion examples
 
Hands-On Lab Data Mining - SQL Server
Hands-On Lab Data Mining - SQL ServerHands-On Lab Data Mining - SQL Server
Hands-On Lab Data Mining - SQL Server
 

Similar to Tutorial%20fivestar%20cck%20views

Obiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboardObiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboardAmit Sharma
 
Obiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboardObiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboardAmit Sharma
 
Obiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboardObiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboardAmit Sharma
 
Bricano Presentation
Bricano PresentationBricano Presentation
Bricano PresentationDinesh Pant
 
01 startoff angularjs
01 startoff angularjs01 startoff angularjs
01 startoff angularjsErhwen Kuo
 
Agile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoAgile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoMoldova ICT Summit
 
Model View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In AspnetModel View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In Aspnetrainynovember12
 
Introduction To ReqPro
Introduction To ReqProIntroduction To ReqPro
Introduction To ReqProLeslie Munday
 
IBM Cognos 10 Framework Manager Metadata Modeling: Tips and Tricks
IBM Cognos 10 Framework Manager Metadata Modeling: Tips and TricksIBM Cognos 10 Framework Manager Metadata Modeling: Tips and Tricks
IBM Cognos 10 Framework Manager Metadata Modeling: Tips and TricksSenturus
 
WAC Widget Upload Process
WAC Widget Upload ProcessWAC Widget Upload Process
WAC Widget Upload Processwacapps
 
Bdd with Cucumber and Mocha
Bdd with Cucumber and MochaBdd with Cucumber and Mocha
Bdd with Cucumber and MochaAtish Narlawar
 
Intland Academy: Requirements Management Training Session | 19 Sep 2019
Intland Academy: Requirements Management Training Session | 19 Sep 2019Intland Academy: Requirements Management Training Session | 19 Sep 2019
Intland Academy: Requirements Management Training Session | 19 Sep 2019Intland Software GmbH
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labsccis224477
 
Balancing UX Consistency and Developer Productivity in a Design System
Balancing UX Consistency and Developer Productivity in a Design SystemBalancing UX Consistency and Developer Productivity in a Design System
Balancing UX Consistency and Developer Productivity in a Design Systemuxpin
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAlfa Gama Omega
 
New Products Web Site
New Products Web SiteNew Products Web Site
New Products Web Sitegenegw
 
Building a Pyramid: Symfony Testing Strategies
Building a Pyramid: Symfony Testing StrategiesBuilding a Pyramid: Symfony Testing Strategies
Building a Pyramid: Symfony Testing StrategiesCiaranMcNulty
 

Similar to Tutorial%20fivestar%20cck%20views (20)

Obiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboardObiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboard
 
Obiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboardObiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboard
 
Obiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboardObiee11g building-brand-analysis-dashboard
Obiee11g building-brand-analysis-dashboard
 
Bricano Presentation
Bricano PresentationBricano Presentation
Bricano Presentation
 
01 startoff angularjs
01 startoff angularjs01 startoff angularjs
01 startoff angularjs
 
Agile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoAgile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai Shevchenko
 
Model View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In AspnetModel View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In Aspnet
 
Introduction To ReqPro
Introduction To ReqProIntroduction To ReqPro
Introduction To ReqPro
 
IBM Cognos 10 Framework Manager Metadata Modeling: Tips and Tricks
IBM Cognos 10 Framework Manager Metadata Modeling: Tips and TricksIBM Cognos 10 Framework Manager Metadata Modeling: Tips and Tricks
IBM Cognos 10 Framework Manager Metadata Modeling: Tips and Tricks
 
Mvc summary
Mvc summaryMvc summary
Mvc summary
 
WAC Widget Upload Process
WAC Widget Upload ProcessWAC Widget Upload Process
WAC Widget Upload Process
 
Building richwebapplicationsusingasp
Building richwebapplicationsusingaspBuilding richwebapplicationsusingasp
Building richwebapplicationsusingasp
 
Bdd with Cucumber and Mocha
Bdd with Cucumber and MochaBdd with Cucumber and Mocha
Bdd with Cucumber and Mocha
 
Intland Academy: Requirements Management Training Session | 19 Sep 2019
Intland Academy: Requirements Management Training Session | 19 Sep 2019Intland Academy: Requirements Management Training Session | 19 Sep 2019
Intland Academy: Requirements Management Training Session | 19 Sep 2019
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labs
 
Balancing UX Consistency and Developer Productivity in a Design System
Balancing UX Consistency and Developer Productivity in a Design SystemBalancing UX Consistency and Developer Productivity in a Design System
Balancing UX Consistency and Developer Productivity in a Design System
 
Unit 2 - Data Binding.pptx
Unit 2 - Data Binding.pptxUnit 2 - Data Binding.pptx
Unit 2 - Data Binding.pptx
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_cs
 
New Products Web Site
New Products Web SiteNew Products Web Site
New Products Web Site
 
Building a Pyramid: Symfony Testing Strategies
Building a Pyramid: Symfony Testing StrategiesBuilding a Pyramid: Symfony Testing Strategies
Building a Pyramid: Symfony Testing Strategies
 

More from tutorialsruby

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 

More from tutorialsruby (20)

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Tutorial%20fivestar%20cck%20views

  • 1. Create a simple rating/review system with a Drupal 6 installation and the latest stable versions of the following modules: • Fivestar • Voting API • CCK This tutorial was written based on testing performed in the following enviroment: • Windows Vista Home Edition • Apache 2.2.8, PHP 5.2.6, MySQL 5.0.51a • Drupal 6.10 • CCK 6.x-2.2 • Fivestar 6.x-1.13 • Voting API 6.x-2.0-rc2 This tutorial will use two content types created using CCK - "Product" and "Review". "Product" is the target node type, or in other words, the node type that is being reviewed by users. Users can submit reviews of Products'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 single rating review system and 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). Single rating review system: Step 1: Create the Product node type using CCK and create a Product Go to admin/content/types/add and create a new node type called "Product" (no quotations). IMPORTANT: CHECK THE "ENABLE FIVESTAR RATING" BOX UNDER THE "FIVESTAR RATINGS" FIELDSET. Votes made by the Review content type will not be calculated unless this box is checked. Then 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 and 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 a single rating field using CCK and create a Review node Go back to admin/content/types/add and create a new node type called "Review" (no quotations). Save the node type and then click "manage fields" for the Review node type. Add a new field with the label "Select the product you wish to review", field name "product_reference", field type "Node reference", and form element "Select list". Under the global settings, make the field required and check "Product" under "Content types that can be referenced". Save the field and add another field with the label "Overall Rating", field name "overall_rating", field type "Fivestar Rating", and form element "Stars". Under Review settings, uncheck "Allow user to clear value". Under Global Settings, check the "Required" box and under "Voting target", select the node reference field "field_product_reference". PHP CODE IS NOT NEEDED -- LEAVE BLANK. VOTING AXIS IS NOT NEEDED FOR SINGLE REVIEW SYSTEM -- LEAVE BLANK. 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 $current_rating = votingapi_select_results(array('content_id' => $node->nid, 'function' => 'average')); print '<div><strong>Rating:</strong>'; print theme('fivestar_static', $current_rating[0]['value'], '5'); //this is for 5 stars, enter 10 (or whatever) instead as appropriate 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. After you have inserted the display code into node-produt.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 wil 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. Multi-axis Rating System: Step 1: Create the Product node type using CCK and create a Product Go to admin/content/types/add and create a new node type called "Product" (no quotations). IMPORTANT: CHECK THE "ENABLE FIVESTAR RATING" BOX UNDER THE "FIVESTAR RATINGS" FIELDSET. Votes made by the Review content type will not be calculated unless this box is checked. Then 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).
  • 2. Save this content type and 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 (Multi-axis Rating System): Create the Review node type with multiple rating fields using CCK and create a Review node Go back to admin/content/types/add and create a new node type called "Review" (no quotations). Save the node type and then click "manage fields" for the Review node type. Add a new field with the label "Select the product you wish to review", field name "product_reference", field type "Node reference", and form element "Select list". Under the global settings, make the field required and check "Product" under "Content types that can be referenced". Save the field and add another field with the label "Reliablity Rating", field name "reliability", field type "Fivestar Rating", and form element "Stars". Under Review settings, uncheck "Allow user to clear value". Under Global Settings, check the "Required" box and under "Voting target", select the node reference field "field_product_reference". PHP CODE IS NOT NEEDED -- LEAVE BLANK. Under voting axis, enter "reliability". Save the field settings. Enter a second rating field with label "Value Rating", field name "value", field type "Fivestar Rating", and form element "Stars". Use the same field settings as the "Reliability Rating" field, but under voting axis, enter "value". Save the field settings. Step 3 (Multi-axis Rating System): 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. After you have inserted the display code into node-produt.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 wil 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. Displaying Fivestar Multi-axis Review Ratings with Views 2.x This tutorial was using Drupal 6.11 and Fivestar 6.x-1.15. After setting up a mult-axis review system using the above instructions, the next logical step would be to display the results using a view. Here are the instructions for building such a view. Step 1: Have a multi-axis review system in place with at least 1 reviewable node and 2 reviews submitted for that node. Following the previously mentioned tutorial, build a review system consisting of a "Product" node type and "Review" node type. "Product" is the node type that will be reviewed by the "Review" node type. "Review" node type will allow users to create reviews of Products and rate the products on multiple axes. 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 2: 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" and make the Path of the page "products". Add a field of type "Node: Title". Add a filter of type "Node: Type" and select "Is one of" and check the node type "Product". Now 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", the Vote tag "reliability", and the Aggregation function "Average". Add a secon Relationship of type "Node: Voting results" - label it "Value Results", make the Value type "Percent", Vote tage "value", and Aggregation function "Average". Now add a field of type "Voting API results: Value". Make the Appearance "Fivestar Stars (display only), the Relationship "Reliability Results" and the Label" "Average Reliability Rating". Add another field of the type "Voting API results: Value". Make the Appearance "Fivestar Stars (display only), the Relationship "Value Results" and the Label "Average Value Rating".
  • 3. 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).