Rate Plugin v0.1

Release Notes

A simple rate plugin. Just install the plugin and add to the object view (blog view for example):

elgg_view('rate/rate', array('entity'=> $vars['entity']));


Enjoy it!

And report feedback please :)






  • im a novice i need to know a little more on how to add this to an entity.

    i guess an entity is a 'blog',  elgg_view('rate/rate', array('blog'=> $vars['entity']));   ????

    if not could you just tell me where abouts i need to put the code folder/.whatever/line number


    i would like to be able to rate my "friends" mini pictures all of them and if i have 10 friends their job is also to rate everyone too and there should be a commulative score (im not asking you to do this as im sure you are busy but it's something my site will need in the future and i could do with some pointers).

    thanks mate

  • I'm trying to enable rating for pages.

    Can anyone indicate where (and or how) I would insert Miguel's codeline:

    elgg_view('rate/rate', array('entity'=> $vars['entity']));

  • Hi, I'm sorry but I'm very busy at the moment. I hope it works on ELGG 1.5 but I haven't tested it yet.


  • For me, It is working with the 1.5... regards.

  • I just added a small modification to your plugin :

    in the rate view :  i added a disabling option to the input form

    if (allow_rate($vars['entity']) && ! $vars['disabled']){

    so when calling the view you can use

    elgg_view('rate/rate', array('entity'=> $vars['entity'], 'disabled' => 1))

    therefore only the result shows up on the object. Useful for the lists (pages home for example)


  • please write small manual how can use this rating plugin.

    Where (and or how) string would be inserted

    elgg_view('rate/rate', array('entity'=> $vars['entity']));

  • Wherever you want to appears it. Usually in other plugins views ;)

  • any chance of adding support to browse by rating?

    or showing top rated items on the home page?

  • I agree knowing where to insert the code would be nice. For instance on whereto insert it on user profiles or blogs or pages or files and even anywhere else. The screenshots posted with plugin may have helped but they are not working.

  • It worked for me by inserting echo elgg_view('rate/rate', array('entity'=> $vars['entity'])); in the mod/profile/views/default/profile/profilelinks.php file (in 1.5). It appears nicely in the profile menu. Haven't looked at other locations, but should work with same method (thus other plugin files in /mod) Good feature that you can't do multiple ratings from a single user btw.

  • This works great.

    I added the following code into the allow_rate function in start.php to not allow the owner of an entity to vote on his/her own items.

    This code goes directly underneath "if (isloggedin()){" in start.php in the allow_rate function:

            $viewer = get_loggedin_user();
            //don't let the owner of the entity vote on stuff they own
            if($viewer->guid == $entity->owner_guid) {
                return false;

  • Just doing some fine tuning...

    I'm trying to get the wording of the "(X Votes)" to align with the star .gifs but it isn't happening. The  (X Votes) text appears to the right and lower than the stars.


    I put a <br> in the code meanwhile (see below) to bring the (X Votes) wording down to the following line to temporarily remedy the weird way it looks though it leaves a lot of space between them.

    echo "<img src='{$CONFIG->wwwroot}mod/rate/_graphics/$image.gif' alt='$rate' title='$rate'/> <br> (".$vars['entity']->countAnnotations('generic_rate')." ".elgg_echo("rate:rates").")";

    I'm new to php so does anyone have any idea of how to put them in line

  • As I read this, you place the provided code in the view for the object you want rates added to.

    IE for blogs this would be something like in the file mod/blogs/view/default/blogs/object/blog.php

    Might be helpful if you look in that file and see how comments are handled to give you an idea of how to do it.

    Could be totally nuts, but, that's how I read it. :)

  • Okay, I have this installed but am getting an error:

    Fatal error: Call to a member function getAnnotationsAvg() on a non-object in /home/XXXX/public_html/mysite.com/mod/rate/views/default/rate/rate.php on line 15


    Is this an error in 1.5?  Not sure how to handle this function.  Any ideas?

  • What would be good for this plugin is to be able to hover over the stars to choose the rating (like in Youtube) instead of clicking on one of the radio buttons.

    Anyone know how to do this?

  • if you save me time going to UTube myself (because i don't what they got) and embed some sample graphics here i might think it over ;-)

  • This rate can work to rate a topic ?

  • yep ;-) should work... you just need to put the code
        elgg_view('rate/rate', array('entity'=> $vars['entity']));
    wherever you want "rating"
    I haven't myself tested it on topics tho ;-(
    maybe you will test and let us all know what happens ;-)

  • Can some one please clarify for me where I need to place Twister's hack:

    if (allow_rate($vars['entity']) && ! $vars['disabled']){

  • :/ It must be something obvious I'm missing, but I cannot get this to work with blogs at all, or profiles for that matter, although I managed that on my (often rebuilt) testsite once. Can't remember how the hell I did it now though!

  • Would love to see you update your plugin. Also, please see discuss here, with regard to TidyPics and your plugin:


  • I had to disable this rating feature because it was conflicting with the site permissions. It would make you have to be logged in to see anything that was set as Public (Blogs etc.).

    For example, if anyone was logged out and wanted to click on one of the blog posts (that was set as 'public') on my index page, they would get redirected back to the same index page instead of to the blog post.


  • Category: Uncategorized
  • License: GNU General Public License (GPL) version 2
  • Updated: 2014-11-17
  • Downloads: 4953
  • Recommendations: 1

Other Projects

View Miguel Montes's plugins