GithubHelp home page GithubHelp logo

hdpero / silverstripe-rateable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sheadawson/silverstripe-rateable

0.0 2.0 0.0 47 KB

An extension that adds a star rating system + UI to any DataObject type

License: BSD 3-Clause "New" or "Revised" License

PHP 40.75% CSS 0.42% JavaScript 58.31% Scheme 0.51%

silverstripe-rateable's Introduction

silverstripe-rateable

An extension that adds a star rating system + UI to any DataObject type

Requirements

Silverstripe 3.1

Installation

composer require sheadawson/silverstripe-rateable 1.1.x@stable

Apply the Rateable DataExtension to the Objects you want to rate. ie. in mysite/_config/config.yml

Page:
  extensions:
    - Rateable

Then in your templates you can use $RateableUI, when in the context of your rateable object to render the star rating UI. If you have multiple instances of the same DataObject + RateableUI on one page, you can pass in a unique identifier string to $RateableUI, ie. $RateableUI('footer').

Run dev/build?flush=all

Sorting objects by rating

$pages = Page::get();
$sortedPages = singleton('RateableService')->sortByRating($pages);

Disabling by default on some page types

If you have added this extension to the Page class, it's enabled by default on all pages. But on some page types this might be annoying, e.g. ErrorPage or some holders. You can disable $RateableUI by default on this pages by adding this to your config.yml:

ErrorPage:
  defaults:	
    EnableRatings: 0

You can still enable it on some pages of this type by hand in the "Settings" section.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.