Version 0.5
Ratings stars - Allow users to vote for pages.
- IP protection - You can only vote one time on one page.
- Secret hidden - code used to prevent simple spam attacks.
- Page methods - Get rating average and rating count.
- Stars snippet - Show the stars in 4 different sizes in the templates.
- Multi language - Including some common languages.
Use one of the alternatives below.
If you are using the Kirby CLI you can install this plugin by running the following commands in your shell:
$ cd path/to/kirby
$ kirby plugin:install jenstornell/kirby-ratings
- Clone or download this repository.
- Unzip the archive if needed and rename the folder to
kirby-ratings
.
Make sure that the plugin folder structure looks like this:
site/plugins/kirby-ratings/
If you know your way around Git, you can download this plugin as a submodule:
$ cd path/to/kirby
$ git submodule add https://github.com/jenstornell/kirby-ratings site/plugins/kirby-ratings
Add this line to your header snippet:
<?php echo css('assets/plugins/kirby-ratings/css/style.css'); ?>
Add the following code to your footer snippet:
<?php snippet('ratings-modal'); ?>
<?php echo js('assets/plugins/kirby-ratings/js/script.min.js'); ?>
<script>
kirbyRatings.init('<?php echo u(); ?>');
</script>
To trigger a rating modal you need something like this:
<div class="rating-trigger" data-id="<?php echo $page->id(); ?>" data-title="<?php echo $page->title(); ?>">Trigger</div>
rating-trigger
The class name has to match exactly.
data-id
Full id that goes to the page that the user is voting for.
data-title
The title of the page in the modal.
Just to be safe
The five rating values stored in the content are counters. Just to be sure you can add them in your blueprint as well.
fields:
rating_1: rating_hidden
rating_2: rating_hidden
rating_3: rating_hidden
rating_4: rating_hidden
rating_5: rating_hidden
Rating in the panel (optional)
To show your rating in the panel, you need to add a field for it.
If you want to see the stars and some information, add this to your blueprint:
fields:
ratings:
title: Ratings
type: ratings
<?php snippet('rating-stars', array('size' => 'large')); ?>
<?php snippet('rating-stars', array('size' => 'medium')); ?>
<?php snippet('rating-stars', array('size' => 'small')); ?>
<?php snippet('rating-stars', array('size' => 'tiny')); ?>
size
The built in sizes are large
, medium
, 'small' and tiny
.
...or add no arguments and small will be used:
<?php snippet('rating-stars'); ?>
<?php echo $page->ratingAverage(); ?>
<?php echo $page->ratingCount(); ?>
ratingAverage
The rating average like 3.52
.
ratingCount
The number of votes like 48
.
c::set('plugin.ratings.blocked.ips', array());
blocked.ips
Add IP numbers manually in an array to block them.
0.5
- Fixed bug with create blacklist.
- Removed the
go
feature again. It was the wrong approach.
0.4
- Fixed bug in js. Not multiple triggers can be added on a single page.
- Font added to success message.
- Box sizing added to submit button.
- Updated docs with minor things.
- Added the optional
go
argument to the modal.
0.3
- Cleaned up some unused functions.
- If rating is not set no stars are displayed.
- If rating is not set the average is
?
instead of 3. - Hidden in blueprint is now hidden in the panel. Bug fixed.
0.2
- Config to manually block IP numbers in an array.
- Added frensh translation. Thanks to Mathieu Etienne for that.
- Added forgotten translation keys to the
en
andsv
translations. - Added support for multi language setup.
- Added global blueprint field definitions to make the blueprint shorter.
- Minified frontend js and included the gulpfile.js.
- Separated stars snippets into a panel snippet and a frontend snippet.
0.1
- Initial release
- Kirby 2.3+
This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.