Powered by MediaWiki
Personal tools

Starrating plugin

From B2evolution

(Redirected from Plugins/starrating plugin)
Jump to: navigation, search

This plugin allows your visitors to rate your posts using star ratings. By default they can rate the posts out of five stars, but it's easy to change that value in the backoffice plugin settings. Users with JavaScript enabled can vote without reloading the page using an AJAX call. The plugin works when JavaScript is disabled by the reader, too. By default, each vote is checked against a list of IP addresses to make sure that it's not a duplicate, but this can be disabled in the backoffice.
The current version seems to support the 1.x version of b2evo only; would be great to get this working for 2.x

This screencap shows the Star Rating Plugin with a pop up notice.
This screencap shows the Star Rating Plugin with a pop up notice.

Contents

[edit] Installation

  1. Download the plugin, and unzip it.
  2. Copy the starrating_plugin folder into the "plugins" folder of your b2evolution installation.
  3. Login to the administrative interface for your blog.
  4. Install the Star Rating plugin from the Settings::Plug-ins::Available plugins table using the [Install] link.
  5. There are two bits of code to place in the _main.php file for any skin where you want the star ratings to be used.

Put this one in the post loop inside the bSmallPrint div or just below the post title:

 <?php $Plugins->call_by_code( 'starrating', array('id' => $Item->ID ) ); ?> 

If you use pop-up notices, which are enabled by default, you need to add this to your skin, just after the opening body tag:

<?php $Plugins->call_by_code( 'starrating', array('display' => 'notice' ) ); ?> 

(Optional) If you want to show the top rated posts in the sidebar, add this code to the sidebar:

<?php $Plugins->call_by_code( 'starrating', array('display' => 'toprated', 'limit' => 5 ) ); ?> 

By default, it shows links to the top five posts, but you can change the 'limit' param to get different results. You can also edit the minvote setting so that a certain number of votes are required before an item can make it into the top rated list.

[edit] Usage

Once you have the plugin installed and the settings the way you want them, then go the write tab and create a post. If you want the post to have the rating system, then make sure that there's a check in the box next to 'Star Rating' in the 'Text renderers' section in the lower right.

Now the stars should appear next to your post. To vote, click on the star you're voting for. If JavaScript is enabled, it will say 'Loading . . .', then display the new rating and thank you for your vote. If JavaScript is disabled, then the page will reload and the new rating will be shown.

[edit] Settings

[edit] Out of

Choose the number of stars possible. The default is five. It's best to only change this value right after installing the plugin. If there are already votes cast using another max value, then your results will be skewed if you change this value. Uninstall the plugin, then reinstall it to clear any old votes, then change the value.

[edit] Check IP

By default, each vote is checked against a list of IP addresses to make sure it's not a duplicate. You can disable the check using this setting.

[edit] Pop-up info

This option, which is enabled by default, displays details about a rating and notices (after you vote) in a JavaScript popup that fades in and then back out after 4 seconds. If you use this feature, be sure to place the additional skin tag (notice) just after your opening body tag (see above). This option requires a little more work to set up and requires that the user have JavaScript enabled, but it is more attractive and does not disrupt your site layout when someone votes.

[edit] Inline info

If you check this box, details about a rating and notices (after a vote) are placed just below the stars. This does not require the notice skin tag or JavaScript, but it may disrupt your site layout when someone votes. It is possible to use both of the info options at the same time, but it could be considered a bit redundant.

[edit] Apply rendering

This plugin doesn't really use a renderer, but it uses the renderer checkbox setting to know which posts should have the star rating available. Edit this plugin setting to set whether the checkbox is checked by default. For example, if you only want a few of your posts to have the rating system, then set 'Apply rendering' to 'opt-in'. Then, posts won't have the stars unless you check the box when you're writing a post. If you want all or almost all of the posts to have the rating system, then set the 'Apply rendering' in the plugin settings to 'opt-out'. Then, all posts will have the stars unless you uncheck the box in the write tab.

[edit] Customization

[edit] Change star image

It's not hard to change the star image. First, download the default image and look at it. It's three stars stacked on top of each other. The top star is the empty version, the middle star is the hover version, and the bottom star is the normal one that shows the average rating. Create your new image to match this template, then upload it to the /starrating_plugin/ folder. Then, edit the stars.css file to match your new file name. If your image has a width that's different than 20px, then you'll need to edit the two lines toward the top of stars.css that set the width. Then edit _starrating.plugin.php and find "var $width = 20;" and edit the value to match your image's width.

[edit] Credits

This plugin was made for b2evolution by Danny Ferguson and it is based on Ajax Rating by Ryan Masuga.

[edit] Known issues

This plugin uses the prototype + scriptaculous library, but b2evolution is supposed to use jquery. This could cause an incompatibility. The next major version of this plugin will be built with jquery.