793

Product support

Get help in the plugin support forum.

  • Added on Oct 26, 2020
  • Current version: 1.0.1
  • Platform Compatibility
    v3.x not tested
    v2.x not tested
    v1.x use latest
  • Created by
  • Public repository

Categories

A simple extension of the Commentable plugin for October CMS that adds the ability to save a rating along with a comment.

Features

  • Ratings for both frontend and backend comments
  • 5 star, thumbs up/down, Plus/Minus etc

Requires

Have a feature suggestion? Found a bug or need support?

Please use the contact form on my website and I'll get back to you as soon as possible. I usually respond within a few hours depending on timezone differences.

5 star ratings comment thread

Installation

  • Install through the markplace or git clone to /plugins/flynsarmy/commentableratings
  • php artisan plugin:refresh Flynsarmy.CommentableRatings
  • Optionally copy views/partials/comments to your themes partials/comments folder to override your comment components default partials, changing to the style of ratings you desire.

If using the example 5 star rating code (requires Bootstrap, Font Awesome and jQuery), add the following CSS to your site:

.star-rating .fa-star {cursor:pointer}
.star-rating .fa-star.checked {color:#eea022}

and JavaScript:

// Make star ratings work in comments
$(document).on('mouseleave', '.commentable .star-rating.settable', function() {
    $('.fa-star', this)
        .removeClass('checked')
        .slice(0, jQuery(':hidden:first', this).val()).addClass('checked');
}).on('mouseenter', '.commentable .star-rating.settable .fa-star', function() {
    $(this).prevAll().andSelf().addClass('checked');
    $(this).nextAll('.fa-star').removeClass('checked');
}).on('click', '.commentable .star-rating.settable .fa-star', function() {
    $(this).nextAll(':hidden:first').val(
        $(this).prevAll().length + 1
    );
});

API

This plugin adds the following methods/properties:

Flynsarmy\Commentable\Models\Thread:

  • getPositiveRatings() - (int) Returns the number comments with ratings above 0.
  • getNegativeRatings() - (int) Returns the number comments with ratings below 0.
  • getAverageRating() - (int) Returns the average rating value of comments with ratings, rounded to the nearest integer.

Flynsarmy\Commentable\Models\Comment:

  • rating - (int) A rating value from -10 to 10.
1.0.1

First version of Commentable Subscriptions

Oct 25, 2020