2017 © Pedro Peláez
 

symfony-bundle star-rating-bundle

Symfony Bundle for simple Star Rating System

image

ideato/star-rating-bundle

Symfony Bundle for simple Star Rating System

  • Friday, August 1, 2014
  • by dymissy
  • Repository
  • 6 Watchers
  • 3 Stars
  • 447 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

StarRatingBundle

StarRatingBundle is a Symfony Bundle for easy star rating system. StarRatingBundle can be used with your own Javascript library but it also includes jQuery Raty plugin if you'd like to install and use the bundle as-it-is., (*1)

Installation

  • Install the bundle via Composer:, (*2)

    composer require ideato/star-rating-bundle "dev-master"
  • Add the IdeatoStarRatingBundle to your application kernel:, (*3)

    // app/AppKernel.php
    public function registerBundles()
    {
            return array(
                // ...
                new Ideato\StarRatingBundle\IdeatoStarRatingBundle(),
                // ...
            );
    }
  • Update the database schema with Doctrine:, (*4)

    app/console doctrine:schema:update --force
  • Include the routing configuration:, (*5)

    #app/config/routing.yml
    _ideato_starrating:
        resource: "@IdeatoStarRatingBundle/Resources/config/routing.yml"

Configuration

In order to include static files in case of you want to use jQuery Raty plugin included, you need to:, (*6)

  • Add the bundle within the allowed Assetic bundles:, (*7)

    #app/config.yml
    assetic:
        #...
        bundles:        [ IdeatoStarRatingBundle ]
  • Load static files:, (*8)

    {% javascripts
        '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'
        '@IdeatoStarRatingBundle/Resources/public/jquery.raty.js'
        '@IdeatoStarRatingBundle/Resources/public/jquery.starrating.js'
    %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}
    
    {% stylesheets
        "@IdeatoStarRatingBundle/Resources/public/jquery.raty.css" filter="cssrewrite" %}
    <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}
  • Install the assets and regenerate static files:, (*9)

    app/console assets:install web
    app/console assetic:dump

Usage

If you chose to use the jQuery plugin included, you simply need to render the star rating controller in your pages:, (*10)

    {{ render(
        controller( "IdeatoStarRatingBundle:StarRating:displayRate", {
            contentId: post.id
        })
    ) }}

You just need to customize the contentId param according to the id of your element. The controller automatically will render the rating stars with the current score enabled. Something like the following screenshot:, (*11)

, (*12)

In this way everything is already enabled and users can start to rate your resources., (*13)

Bonus

You can completely rewrite the rating logic within the jquery.starrating.js. The easiest way is to copy and paste the file within your bundle and use your own Javascript file., (*14)

TODO

  • Add new table for registering single rate
  • Prevent multiple vote

The Versions

01/08 2014

dev-master

9999999-dev http://github.com/ideatosrl/StarRatingBundle

Symfony Bundle for simple Star Rating System

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony star-rating ideato