Log in

Pedro Prez

elgg developer / php / ajax and more

Stats

  • Category: Communication
  • License: GNU General Public License (GPL) version 2
  • Updated: 2010-7-12
  • Downloads: 13600
  • Recommendations: 55

Other Projects

View Pedro Prez's plugins

Likes for Elgg 1.0

This module allows to mark the objects as "I like it" as facebook style ;)

Last updated 1375 days ago

The module allow a user to mark objects by default on its creation, for example, when a blog creates or a pages, etc.

There is a easy way to put it in another views just take a look to the INSTRUCTIONS.txt file.

You can test this module logging in on http://demo.keetup.com Thanks!

if you really like this plugin recommend it, I would really appreciate it

Release Notes:

This module allows to marc the objects as "I like it" and "I dislike it" as facebook style ;)

** CHANGES in this release **   

* Added the option that automaticaly adds all the functionalities to the rivers.   

* Added the functionality dislike, this has been rewritten (thanks bman!)   

* Allows that all the elements can be effected with a "like" action, comments, creations or updates.

-Compatible with riverfaces.

-Fixed some bugs

 

** TODO for future releases **   

* Make an statistics page (view) to know what are the elements that people likes more (Trajan 's idea)   

* Show with a lightbox all the users that liked an object.   

* Make the actions to be executed with AJAX.

**** Recomendations ****

If you also have the dislike plugin you need to disable it.

Comments

  • Pedro Prez 1426 days ago

    @Trajan this new version fix all your issues.

    Cheers

  • Trajan 1426 days ago

    @Pedro it's looking that way thanks.

    I'm still getting 2 dislike buttons. But only 1 like button in the river.

    I'm on an elgg 1.6.1 using 3 column riverdashboard with riverfaces.

    Also I can't find statistics anywhere.

    Keep up the good work! I think they should add this to core. It's something very useful and a small filesize.

  • Pedro Prez 1426 days ago

    Can you send me a screenshot? Thanks

  • chambo67 1426 days ago

    I had the same issue, with the prev version, now with this version it works perfectly, thanks for a kickass plugin, how u guys doing with trying to get commenting on this plugin??

  • Severin Alex 1426 days ago

    it will be great with commenting!!!

  • Trajan 1426 days ago

    Sorry it was late at night and I'd had a few drinks before getting back home. I still had the dislikes plugin enabled! All good now.

     

  • maikol 1425 days ago

    Thank you very much for the plugin, but I wonder if I like it when pressed, do not refresh the page, this plugin uses AJAX as facebook.

  • chambo67 1425 days ago

    Yea, if it could somehow use the same behaviours like the wall to wall plugin, that would be sweet.

  • Artist Craze Media 1425 days ago

    Thanks for the updates. I like the Ajax idea completely. Let us know if you'd like to collab!

  • citella 1423 days ago

    I do some modifications to this plugin, because it not work very well.

    When i click "I like" on one item, when the page refresh, the plugin shows me both, the voice unlike with thumb in up direction (this is already not consistent because i aspect the thumb in down direction) and  the voice dislike.
    I think it ismuch clearer, if i have only the voice unlike with  thumb in down direction.
    The same thing if someone click on dislike. In this case, should see only the voice undislike with  thumb in up direction.
    You think ?

     

    So i modify file \likes\view\default\likes\likes.php  and the file

    \likes\view\default\likes\css.php .

    First file \likes\view\default\likes\likes.php

     

    <?php
        /**
        * likes
        *
        * @author likes
        * @link http://community.elgg.org/pg/profile/pedroprez
        * @copyright (c) Keetup 2010
        * @link http://www.keetup.com/
        * @license GNU General Public License (GPL) version 2
        */

        $object = $vars['entity'];
        if (!$object instanceof ElggEntity) {
            return false;
        }
        $item = $vars['item'];
       
        $action_name = $vars['action_name'];
        if (!$action_name) {
            return false;
        }
       
        $annotation_name = $action_name;
        //If the view is called from the riverdahsboar then we make a special annotation
        if ($item) {
            $annotation_name .= "_{$item->id}";
        }
       
        $annotationno="dislike_".$item->id;
        $annotationsi="like_".$item->id;
        //We count the quantity of people that likes this.
        $likes_no = (int) count_annotations($object->getGUID(), "", "", $annotation_name);
       
        if ($object instanceof ElggEntity && isloggedin()) {
            //Do you like this object?
            $doyoulike = false;
           
            //Now we check if the user that is logged in likes this object.
            $likes_no_by_userno = count_annotations($object->getGUID(), "", "", $annotationno, 1, '', get_loggedin_userid());
            $likes_no_by_usersi = count_annotations($object->getGUID(), "", "", $annotationsi, 1, '', get_loggedin_userid());
           
            if (($likes_no_by_usersi > 0 and $annotation_name==$annotationsi) or ($likes_no_by_userno > 0 and $annotation_name==$annotationno) ) {
                //You already liked it
                $doyoulike = true;
                $annotation = get_annotations($object->getGUID(), "", "", $annotation_name, 1, get_loggedin_userid(), 1);
                if (!empty($annotation)) {
                    $annotation = array_shift($annotation);
                }
                $link = "{$vars['url']}action/unannotate?action_name=$action_name&like_id={$annotation->id}" . url_compatible_mode('&');
                $content .=  "<a href=\"$link\">" . elgg_echo("un$action_name") . "</a> · ";
                $classe="un".$action_name;
            } else if ( ($likes_no_by_usersi > 0 and $annotation_name==$annotationno) or ($likes_no_by_userno > 0 and $annotation_name==$annotationsi ) )  { $classe=$action_name;}
             
            else   {
             
                //You can like it
                //always generate missing action tokens
               
                $link = "{$vars['url']}action/annotate?action_name=$action_name&river_item={$item->id}&guid={$object->guid}&annotation={$annotation_name}" . url_compatible_mode('&');
                $end_sentence = ($likes_no > 0 ? ' · ' : '');
                $content .=  "<a href=\"$link\">" . elgg_echo($action_name) . "</a>$end_sentence";   
                $classe=$action_name;
            } // if ($likes_no_by_user > 0) {
           
            if ($likes_no > 0) {
               
                // If more than two users, and if you are not there then the translation must finish with: 3 people likes it (like:lotofpeoplelikethis)
                // If more than two users, and you are in that list then the translation must finish with: you and 2 more people likes it.
               
                // If there are two users that likes it and you are not then the translation must be: user1 and user2 likes it. (like:others2likethis)
                // If there are two users that likes it and you are not then the translation must be: user1 and you likes it. (like:otherandyoulikethis)
               
                // If just one user likes it and that user is you then it must say: You likes it. (like:youlikethis)
                // If just one user likes it and that user is not you then it must say: user1 likes it. (like:otherlikesthis)
               
                if ($likes_no < 3) {
                    $annotations = get_annotations($object->getGUID(), "", "", $annotation_name, "", "", $likes_no);
                   
                    $first_annotation = current($annotations);
                    $user = get_entity($first_annotation->owner_guid);
                    $username = "<a href=\"{$user->getURL()}\">$user->name</a>";
                   
                    if ($likes_no == 1) {
                        if ($doyoulike) {
                            $content .= elgg_echo("$action_name:you{$action_name}this");
                        } else {
                            $content .= sprintf(elgg_echo("$action_name:other{$action_name}sthis"), $username);
                        }
                    } else {
                        $last_annotation = end($annotations);
                        $user2 = get_entity($last_annotation->owner_guid);
                        $username2 = "<a href=\"{$user2->getURL()}\">$user2->name</a>";
                       
                        //Likes == 2
                        if ($user == get_loggedin_user() || $user2 == get_loggedin_user()) {
                            //TODO Make it better.
                            if ($user2 == get_loggedin_user()) {
                                $aux = $username;
                                $username = $username2;
                                $username2 = $aux; 
                            }
                            $content .= sprintf(elgg_echo("$action_name:otherandyou{$action_name}this"), $username2);
                        } else {
                            $content .= sprintf(elgg_echo("$action_name:others2{$action_name}this"), $username2, $username);
                        }
                    } //if ($likes_no == 1) {
                } else {
                    if ($doyoulike) {
                        $content .= sprintf(elgg_echo("$action_name:youandalotofpeople{$action_name}this"), "<strong>" . sprintf(elgg_echo("like:others"),$likes_no-1) . "</strong>");
                    } else {
                        $content .= sprintf(elgg_echo("$action_name:lotofpeople{$action_name}this"), "<strong>" . sprintf(elgg_echo("like:others"),$likes_no). "</strong>");
                    }
                } //if ($likes_no < 3) {
            }
            echo "<div class='likes $classe'>$content</div>";
        } //if ($object instanceof ElggEntity && isloggedin())

     

     

     

    Second file \likes\view\default\likes\css.php

     

    <?php
        /**
        * likes
        *
        * @author likes
        * @link http://community.elgg.org/pg/profile/pedroprez
        * @copyright (c) Keetup 2010
        * @link http://www.keetup.com/
        * @license GNU General Public License (GPL) version 2
        */
    ?>
        .likes {
            margin: 4px 0 4px 0px;
            padding: 0px 0 0 17px;
            float:left;
        }
       
        .like {
            background: url(<?php echo $vars['url' ] ?>mod/likes/graphics/like.gif) no-repeat;
            float:left;
        }
       
        .unlike {
            background: url(<?php echo $vars['url' ] ?>mod/likes/graphics/dislike.gif) no-repeat;
            float:left;
        }
        .undislike {
            background: url(<?php echo $vars['url' ] ?>mod/likes/graphics/like.gif) no-repeat;
            float:left;
        }
        .dislike {
            background: url(<?php echo $vars['url' ] ?>mod/likes/graphics/dislike.gif) no-repeat;
            float:left;
        }
       
        .river_item .likes {
            font-size: 0.9em;
            margin: 4px 0 0 15px;
            padding: 2px 0 0 17px;
        }
       
        .likes strong {
            font-weight: bolder;
        }
       
        /*Fix for riverfaces*/
        .river_item_list .likes {
            display: none;
        }
        .river_item_list .river_item .likes{
            display: block;
            margin:10px 0 0 25px;
        }

     

  • Pedro Prez 1423 days ago

    @citella The idea is good, I will try to do this on the next releases, thanks.

    @maikol and @Artist Craze Media  I'm thinking to release a new version today with ajax support ;)

    @Severin Alex and @chambo67 I will to release a new version with these features very soon

    Thanks to everybody for the feedback.

  • enadri 1423 days ago

    It would be nice if the Like plugin is compatible with this video plugin :

    http://community.elgg.org/pg/plugins/rjcalifornia/read/491143/milockercom-video-plugin

  • Pedro Prez 1423 days ago

    @enadri this plugin works fine with videolist plugin try update to the last release.

    Cheers

  • enadri 1422 days ago

    Great Pedro, you are a wonderful dev !