If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

Star rating widget


A patch for plugin_wiki is available too. Or get a patched version. You have choice ;-)


I took "this" rating plug-in and modified little bit. This plug-in uses jQuery extension and I'm aware that there is a better "star rating" jQuery plug-in. I've plan to port this plugin to use that js library.

But for less complex things, this plugin will suffice. dependency is so small. (other one need jQuery-ui too & I prefer to make my client to download as less content as needed.)


Syntax

{{=plugin_rating('shout',1)}}
#or to use split stars
{{=plugin_rating('shout',1, True)}}

If Table shout has a field called 'rating' average rating will be updated there too. If it's not there, it'll work as before.

This version now support some things that's not there in original version

  1. Error fixes

  2. It uses same syntax as original plug-in (so home back again)

  3. support to include more than one rating widget per page.

  4. If the parent table for which we are using rating has a field called 'rate' of type dobule, then average rating will be added to that field too. It'll be handy, if we have to run complex queries on that table involving rating. So, this make less db calls. Also, this degrades gracefully, if there's no 'rating' field in the table without making any noise.

  5. Added support to display rating widget for same record more than once in a page.

  6. Split stars is supported now.

To download the plug-in, please visit "download"

Looking forward to here your comments and possible features that can be added. (I know, it doesn't support callback functions now, may be I release another one that uses star rating jq plugin for that to make this one simple and lean)

Related slices

Comments (2)

  • Login to post



  • 0
    kra3 1 year ago

    I'll try to make some sample code as soon as I've some time.

    {{=plugin_rating('shout',1, True)}} 

    That is used when we need split stars.

    That'll enable users to give ratings like 4.5 instead of whole numbers.

     

    If you include a field called `rating` of type double, average rating will be updated in that column.

     

    I'm a little behind with web2py, had to see with latest version to understand that 'manage' page part.


  • 0
    darin-hosking-10382 1 year ago

    Any chance you could work up some examples on how tis drops in for us new to web2py guys?

    Such as where do I use this? 

    {{=plugin_rating('shout',1, True)}}

    or if I have a table called "issues" do I include a field called "ratings" and if I do what type?

    If I use a default "manage" page from the wizard how would I leverage this widget?

    Some sample code would be great :)

    Thanks in advance


Hosting graciously provided by:
Python Anywhere