Adding "likes" to objects

Does anyone know how to add the "likes" plugin to an object view?  for instance I would like to add the "likes" feature to "the wire" object so I add

echo elgg_view('input/like', array('entity' => $vars['entity']));

to mod->thewire->views->default->object->thewire.php and nothing shows up.  Im using 1.7.10

  • A few points:

    1. Upgrade to 1.7.15 because 1.7.10 has security issues. Do it now, even if it breaks plugins. It's that important.
    2. Make sure you're changing an overriden view instead of the core view itself. Info here.
    3. It's a bug in the likes plugin. You'll have to contact the original dev, or try to fix it yourself.

  • @ brett what are the security issues?  Its sounds big.

  • Look at the changelog it spells it all out.  It is important.

  • Ed posted this.

    If you want to add this to individual pages, you can extend those views with things like this, which can go a start.php file either in the original likes plugin or somewhere else:

    elgg_extend_view('object/blog', 'likes/item_action', 600);
    elgg_extend_view('object/page', 'likes/item_action', 600);
    elgg_extend_view('object/file', 'likes/item_action', 600);
    elgg_extend_view('object/bookmarks', 'likes/item_action', 600);
    elgg_extend_view('object/tidypics', 'likes/item_action', 600);

    This will put a little "like" link at the bottom of the object page.

    But you will discover a weird problem. You can like an item in the river separately and the item itself. The reason is because when you like something from the object page, the annotation name is just "like" and then it is linked to the object id. But if you like something from the river, it adds the river id to the annotation name, and therefore a new name is a new annotation. So.... if you want to do this, you need to remove the blocks in the files annotate.php and element.php that look like this:

    //If the view is called from the riverdahsboar then we make a special annotation
        if ($item) {
            $annotation_name .= "_{$item->id}";
        }

    It worked but then it only displays like or unlike. It doesnt show who or how many people liked it. does anyone know how to add likes to an object AND who/how many people liked it?

  • echo elgg_view('input/like', array('entity' => $vars['entity']));

     

    this only shows likes on the object that are linked to the object id. But if you like something from the river, it adds the river id to the annotation name, and therefore a new name is a new annotation.

    does anyone know how to show the same "likes" that appear in the river in the object view?

  • Please don't bump and double post. If you got no answer, it usually means that your question/problem is not clear.

    Are you still using this plugin and Elgg 1.7? This thread has almost 2 years now. That's ages! Some refresh on your current problem might be nice. Are you really trying to do the same thing for almost 2 years??

    Note that since 1.8 there's bundled likes plugin in the core and 1.7 will become unsupported very soon.

  • How come everytime I ask a question to the community the answer is alway "upgrade to 1.8"? I dont want to upgrade. In my opinion 1.8 looks cluncky and I've done a ton of Dev for 1.7. Even if I do change to 1.8 in the future I'm afraid that if I have a question then that the response will be " upgrade to 1.9" in my opinion that's not a satisfactory response, if you don't wish to help the 1.7 community then don't reply. Its that simple. Maybe this site should open an "all things legacy" group where we 1.7ers won't be belittled for using an outdated engine.

  • I'm just mentioning as we mention to anyone who happen to still run 1.7 install. Of course nobody will force it on you, but it's good to be aware of consequences (like there won't be any official security fixes for this version). That's the way every software moves forward and Elgg IMHO has a very lenient policy and we put very strong emphasisis on maintaining as much backward compatibility as possible. If you wish to discuiss more, please create new thread, let's keep this one focused on original issue.

    Maybe you wouldn't feel "belittled" if you actually gave here some info to work with. The topic is 2 years old. I think that's reasonable assumption that original problem has changed. That's why I asked for info on your current situation. It's not obvious that you still run 1.7. I don't mean to mock you, but trying to get some details from you so you could get help.

    I must admit, I'm supprised that you've made no progress on the problem in the meantime and just happen to jump back on the topic after such long delay. Forgive me for that, but it's unusual.

  • Yes this is a problem I have had for two years but Its not a problem I've been working on for two years. I've posted updates to this problem for a week now with three new posts. I'm not trying to get people to just fix all my issues I'm just seeing if anyone in the community has came across this problem. The problem is in the "likes" plugin there are instructions to add likes to objects but the problem is

    echo elgg_view('input/like', array('entity' => $vars['entity'])); 

    Is only showing the likes for the object id but the likes on the river are tied to a river Id. The question is how do I show the likes that are associated to the river id to show in the object view?