Allow visitors to rate records ...

Installation

  • In a console, from your project root dir, run:
git clone git://github.com/altrano/dmRatablePlugin.git plugins/dmRatablePlugin  
  • In config/ProjectConfiguration.class.php, add dmRatablePlugin to the list of enabled plugins:
class ProjectConfiguration extends dmProjectConfiguration
{  
  public function setup()  
  {  
    parent::setup();  
 
    $this->enablePlugins(array(  
      // your enabled plugins  
      'dmRatablePlugin'  
    ));  
  • In a console, from your project root dir, run:
php symfony doctrine:generate-migrations-diff  

php symfony doctrine:migrate  

php symfony dm:setup  

dmRatablePlugin provides a Doctrine behavior, controllers, templates and assets to set up a rating system quickly.

Doctrine behavior

To declare that a model is ratable, add the behavior in your config/doctrine/schema.yml file:

Article:  
  actAs:  
    DmRatable:  

Run migrations and update the model:

php symfony doctrine:generate-migrations-diff  
php symfony doctrine:migrate  
php symfony dm:setup  

A new table, article_rate, is created to store the article rates.

Display rating stars

Include the plugin assets in your apps/front/config/view.yml file:

stylesheets:  
  - dmRatablePlugin.stars  
  - ...  

javascripts:  
  - lib.ui-core  
  - lib.ui-widget  
  - dmRatablePlugin.stars  
  - ...  

Include the dmRatable/rating component from your record template.

include_component('dmRatable', 'rating', array('record' => $article));  

JavaScript

To enable the jquery.stars plugin, paste the following code to your web/js/front.js file:

$('.dm_ratable_rating').each(function() {  
  var $this = $(this).stars({  
    inputType: "select",  
    callback: function(ui, type, value){  
      $this.find('.message').html(value==ui.options.cancelValue ? "Rating removed" : "Rating saved! ("+value+")").stop().css("opacity", 1).fadeIn(30);  
      setTimeout(function(){ $this.find('.message').fadeOut(1000) }, 2000);  
      $.ajax({  
        type:     'POST',  
        url:      $this.find('form').attr('action'),  
        data:     { hash: $this.attr('data-hash'), value: value, type: type },  
        success:  function(data) {  
          if(data.new_value) {  
              $this.stars('select', newValue);  
          }  
        }  
      });  
    }  
  });  
});  

Then customize it to fit your needs.

Admin

To show the rating of each record in its admin module, add a _rating partial:

# apps/admin/modules/article/config/generator.yml  

  list:  
    display:  
      - _rating  

# apps/admin/modules/article/templates/_rating.php  

<?php  
echo sprintf('%d/%d',  
  $article->getRating(),  
  $article->getTable()->getTemplate('DmRatable')->getOption('max_rate')  
);  
  • rabBroageNovember 14, 2012 10:15 PM

    As already mentioned, the fact that the purpose of the these be aware of where they are going for the loan. [url=http://www.paydayloanspro.org/]payday loans[/url] It should have skilled and trained payday expenses, home of loan company for several purposes, if you feel so. These credit ratings are just averted because and have of compare payday which is where they get their name. Anybody can easily avail the benefits of Unsecured loans and opposite loans the not to cater for your needs efficiently.

  • ReotaBopsoatoyiMay 11, 2013 8:44 PM

    Including all these major care is laid on new iPad? <a href="http://toomanyhorses972.wordpress.com">http://toomanyhorses972.wordpress.com</a> Hoagie intends to signification these bikes into India and grocery store them.

  • RuiguebionoAugust 2, 2013 6:52 PM

    Prada Handbags Outlet - Chanel Handbag - Brief Information To Channel Products
    Hello there, friendWe are reliable and professional supplier which can offer so many brand products in good quality and competitive prices. During '03, Soaked appeared to be made use of by a Liz Claiborne Corporation. You can find the tournaments going to be conducted by them along [url=http://maruta.be/cheappradabags]prada purses[/url] with the bet limit for each game.

    The dial is performed is matte black with a diamond design guilloche pattern. The chronograph [url=http://www.mwpcommunityaid.com.au/?celinehandbags#GrQIJ]celine purses[/url] design has a few recessed sub-dials with green numbers and fingers. In some scenarios, delivery and present wrapping are cost-free, so what are you waiting for? Get on-line and pick out the ideal today. Cheap designer purses is an outstanding option.

    These low cost designer bags [b]prada handbags outlet[/b] might not be as extravagant and as top quality in top quality as the substantial-priced designer bags but they are obviously as quite and as long lasting. Hermes merchandise are definitely a head turner and a should for anyone who price fashion, luxury and vogue. Your mom's garments shouldn't be given [url=http://www.martincountygis.com/controls/celinehandbagssale.html#IxinE]prada handbag[/url] to Goodwill right up until you have observed if they could have oversized silk scarves, which have grow to be modern after [url=http://www.accel-gmbh.de/controls/pradahandbags.html#cfgOG]cheap prada handbags[/url] far more. [url=http://www.haggaibank.com/gallery/pradabagssale.html]prada handbags outlet[/url] Hermes

  • RuiguebionoAugust 5, 2013 7:04 PM

    Hermes Belt | Strike Our Prime Path Along With Lv Baggage
    Do you know what has made the brand popular? It is nothing but the X-factor [url=http://www.intergpomed.com/hermeshandbags.aspx#wQOnQ]hermes handbags[/url] designs of the ornaments that has lured as lot of wearers from all across the world. Recent times have seen an increase in the demand for replica handbags. Several factors may be attributed to this including the hard economic times or the mere fact that people have become smart shoppers realizing they can find an excellent alternative to designer handbags at a much cheaper rate. [b]hermes belt[/b]

    The first thing you need to know is where to find replica handbags. The above mentioned points are like few drops of water in the ocean. [url=http://hermeshbelts.over-blog.com#PKDJb]hermes h belt[/url] Honestly, as I get nearly all these on procuring and [url=http://maruta.be/hermesoutletonline]hermes bags[/url] advertising value decrease revenue marked lessening Mulberry Clutches, We have a tendency to not anticipate the majority of individuals budget friendly handbags are valid [url=http://hermesoutletsale.centerblog.net]hermes birkin[/url] Mulberry clutches. The [url=http://www.accel-gmbh.de/controls/hermesbelts.html#xaMuh]hermes belt[/url] company has positioned itself as the premier handbag designer not only in the UK but also worldwide as Mulberry bags are extremely popular in the United States and the Far East.

    With the world economy teetering between recession and recovery and the credit crunch hitting everybody's pockets it did come as a

  • XRumerTestAugust 31, 2013 4:55 AM

    Hello. And Bye.

  • Pt5EWpixe0November 26, 2013 7:04 PM

    give your ex some space and some time to really miss

    [url=http://xinchuan.njnu.edu.cn/geoguanli/airpresto.asp]Nike Air Presto billig[/url]

    [url=http://www.pgai.com.au/wp-includes/login.php]nike free dk[/url]

    [url=http://www.indiastoneexport.com/nikefree3.html]nike free run 3[/url]

    [url=http://www.svetplus.com/wms/Uggboots.html]UGG ブーツ アウトレット[/url]

    [url=http://www.svetplus.com/rss/novine/Uggshoes.html]アグ ムートンブーツ[/url]

  • Zp4KWmxzf3December 4, 2013 11:50 AM

    . If you've done a good job selecting the apron, everyone

    [url=http://www.no2minutewarning.com/lebron-10-shoes.php]nike lebron 10[/url]

    [url=http://www.no2minutewarning.com/nike-lebron-9.php]lebron 9 shoes[/url]

    [url=http://www.stevegellerfacts.com/news.php]kobe 8 elite[/url]

    [url=http://www.svetplus.com/images/zoomkdvi.html]Nike Zoom KD sale cheap[/url]

    [url=http://www.apbo2010.com/nbashoe.php]nike basketball shoes[/url]

Add a comment

Impossible to fetch issues for this plugin.
Impossible to get this plugin changelog.

dmRatablePlugin, created on September 14, 2010 by altrano, used by 76 projects

Fork Diem on GitHub