Like plugin

How to set the like plugin to only one page in elgg(for example i wana set the plugin to only file page and not to blog page). Please anyone answer me soon as it is urgent

  • You need to add a view to your theme.

    1. Copy <your Elgg directory>/mod/likes/views/default/likes/button.php  to
      <your Elgg directory>/mod/<your theme directory>/views/default/likes/button.php

    2. Now, modify the the copied button.php and add the follwing 2 lines of code as follow:

    <?php
    /**
     * Elgg likes button
     *
     * @uses $vars['entity']
     */

    if (!isset($vars['entity'])) {
        return true;
    }

    // These are the 2 lines of code!
    if (!$vars['entity'] instanceof ElggFile)
            return true;
    //


    $guid = $vars['entity']->getGUID();

    ...........

  • I am using latest 1.8.6 elgg version with cool theme, How i can remove like button when two users become friends?

    I can see in activity feeds when two users become friends there shows LIKE button. How I can remove LIKE option when two people become friends?

     

     

  • There is no like button in activity feed when two members become friends using Elgg bundled Like plugin.  Probably this is different when using Cool theme. What for theme is this? do you have a link for this theme?

  • @kisssssss4ever   Ok, I have found this theme.

    You need to add the following 2 lines of code in <your Elgg directory>/mod/cool_theme/views/default/likes/river_footer.php:

    <?php
    /**
     * Elgg likes display
     *
     * @uses $vars['entity']
     */

    if (!$vars['item'] instanceof ElggRiverItem || $vars['item']->annotation_id) {
        return true;
    }

    // These are the 2 lines of code!
    if ($vars['item']->getView()=='river/relationship/friend/create')
            return true;
    //

    $object = $vars['item']->getObjectEntity();

    ..............

     

     

  • @ElggCloud THANK YOu SO MUCH for your prompt reply, I did try what you said but does not work, still I can see the LIKE button when two users become friend, I don't mind if the LIKe button is there but the problem is when we  press that LIKE button it gives fatal error. 

    Like button works fine everywhere on the site only when two users become friend then that LIKE button gives error :(

  • 1.  If you added this new view /mod//views/default/likes/button.php as I showed before, you have to deactivate and then activate your theme plugin. Don't forget :-) 

    2. Your theme plugin must be placed after like plugin. Usually, you would put this as the last plugin on the bottom.

     

  • @ElggCloud :) Before you told me to edit <your Elgg directory>/mod/cool_theme/views/default/likes/river_footer.php:

    But now above u said edit /mod//views/default/likes/button.php


    Please let me know which one I really need to do :)

    Sorry being a pain, I am new to elgg but hope you would bear with me and try to help me with a smile :)

     ElggCloud am not sure u answered to me or to sharon :(

    Regards

  • @kisssssss4ever  /mod/views/default/likes/button.php was meant for Sharon :-)

    Regarding your issue with Cool theme, you just need to add the following 2 lines of code in <your Elgg directory>/mod/cool_theme/views/default/likes/river_footer.php:

    <?php
    /**
     * Elgg likes display
     *
     * @uses $vars['entity']
     */

    if (!$vars['item'] instanceof ElggRiverItem || $vars['item']->annotation_id) {
        return true;
    }

    // These are the 2 lines of code!
    if ($vars['item']->getView()=='river/relationship/friend/create')
            return true;
    //

    $object = $vars['item']->getObjectEntity();

    ..............

  • @kisssssss4ever  The complete solution for your issue is as follow:

    1)  Modification in <your Elgg directory>/mod/cool_theme/views/default/likes/river_footer.php:

    <?php
    /**
     * Elgg likes display
     *
     * @uses $vars['entity']
     */

    if (!$vars['item'] instanceof ElggRiverItem || $vars['item']->annotation_id) {
        return true;
    }

    if (strpos($vars['item']->getView(), 'river/relationship/friend/create') !==false ||
       strpos($vars['item']->getView(), 'river/relationship/member/create') !==false )
         return true;

    $object = $vars['item']->getObjectEntity();

    .......

    The above added code will prevent already existing likes to be shown on the river.

     

    2)  Modification in <your Elgg directory>/mod/cool_theme/start.php:

    function facebook_theme_river_menu_handler($hook, $type, $items, $params) {
        $item = $params['item'];

        $object = $item->getObjectEntity();
        if (!elgg_in_context('widgets') && !$item->annotation_id && $object instanceof ElggEntity) {
            
            if (elgg_is_active_plugin('likes') && $object->canAnnotate(0, 'likes')) {
                if ($object->type != "user") {
                        if (!elgg_annotation_exists($object->getGUID(), 'likes')) {
                            // user has not liked this yet
                            $options = array(
                                'name' => 'like',
                                'href' => "action/likes/add?guid={$object->guid}",
                                'text' => elgg_echo('likes:likethis'),
                                'is_action' => true,
                                'priority' => 100,
                            );
                        } else {
                            // user has liked this
                            $options = array(
                                'name' => 'like',
                                'href' => "action/likes/delete?guid={$object->guid}",
                                'text' => elgg_echo('likes:remove'),
                                'is_action' => true,
                                'priority' => 100,
                            );
                        }
                        $items[] = ElggMenuItem::factory($options);
                }
            }

            ........

    }

    The above added condition will prevent like menu to be created for friendships on the river.

     

     

     

     

  • Thknk you so much ElggCloud its working fine.... :)