Skip to content

dnadesign/silverstripe-elemental-ratingblock

Repository files navigation

SilverStripe Elemental Rating Block

A rating block for SilverStripe CMS using the Elemental module. This module allows users to rate pages and provide feedback through a customizable rating system.

Requirements

  • SilverStripe Framework ^5
  • SilverStripe GraphQL ^5

Installation

Install via Composer:

composer require dnadesign/silverstripe-elemental-ratingblock

Run dev/build to create the database tables:

vendor/bin/sake dev/build

Basic Usage

  1. Add the Rating Block to your page through the CMS
  2. Configure the rating form settings
  3. Set up star ratings and tags as needed
  4. The rating form will appear on the frontend for users to submit ratings

Configuration

CMS Streamlining

You can streamline the CMS experience by hiding unnecessary fields and tabs:

DNADesign\Elemental\Models\ElementRatingBlock:
  # Hide specific fields in the CMS
  hide_enable_rating_form: true
  hide_rating_form_intro: true
  hide_enable_rating_comments: true
  hide_rating_form_title: false
  hide_rating_form_success_message: false
  hide_enable_rating_tags: false

  # Remove entire tabs
  remove_settings_tab: true

DNADesign\Elemental\Admins\RatingAdmin:
  # Customize admin interface
  hide_main_ratings_tab: true

Configuration Options

ElementRatingBlock Configuration

  • hide_enable_rating_form: Hide the "Enable Rating form" checkbox
  • hide_rating_form_intro: Hide the rating form intro HTML editor
  • hide_enable_rating_comments: Hide the "Enable Rating comments" checkbox
  • hide_rating_form_title: Hide the rating form title field
  • hide_rating_form_success_message: Hide the success message HTML editor
  • hide_enable_rating_tags: Hide the "Enable Rating form tags" checkbox
  • remove_settings_tab: Remove the entire Settings tab from the CMS

RatingAdmin Configuration

  • hide_main_ratings_tab: Hide the main Ratings tab in the admin (useful when you only want to manage rating blocks, not view individual ratings)

Default Star Configuration

You can set up default stars and tags that will be created automatically:

DNADesign\Elemental\Models\ElementRatingBlock:
  stars:
    poor:
      tags:
        - poor
        - very poor
        - extremely poor
    fair:
      tags:
        - fair
        - very fair
        - extremely fair
    good:
      tags:
        - good
        - very good
        - extremely good
    excellent:
      tags:
        - excellent
        - very excellent
        - extremely excellent

UniqueID Field

RatingTag models now include a UniqueID field that is automatically generated from the Name field. This is useful for frontend integration and API consistency.

The UniqueID is generated by:

  • Converting to lowercase
  • Replacing "&" with "and"
  • Replacing spaces with hyphens
  • Removing non-alphanumeric characters (except hyphens)

Example: "Very Good & Great" becomes "very-good-and-great"

Frontend Integration

The rating block automatically includes the necessary CSS and JavaScript files. The rating form data is available through the getBootData() method which provides:

  • EnableRatingForm
  • RatingFormTitle
  • RatingFormIntro
  • EnableRatingComments
  • RatingFormSuccessMessage
  • RatingPageName
  • RatingPageID
  • RatingStars
  • SecurityToken

Permissions

The module includes the following permissions:

  • VIEW_RATING: View ratings in the admin
  • DELETE_RATING: Delete ratings from the admin

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •