XF 1.2 Show All Likes

LuvMeSumZen

Active member
Would it be possible to edit the likes_summary and/or likes_summary.css to enable all Likes to be visible beneath a post, and get rid of the "and 9 others like this" feature?
 
Maybe I should have asked a different way because perhaps those aren't the correct templates. Does anyone know how to change a template/s to enable all likes to be visible beneath a post and do away with the "and X others like this" feature? Maybe it would be very complex to change?
 
I am also interested in this. If you figure it out, please post it here. If I can figure it out beforehand, I will do the same.

It's not looking good. This is the only question I've ever posed here that has gotten a goose egg. Maybe it's too difficult after all. I figured it couldn't be that hard to change but evidently . . .
 
I'm interested in hearing a solution to this one too. I've always thought that a likes-list comprised of small avatars would be nicer.
 
Agreed. I'd think either 5 or 10 visible "likes" as avatars would be nice and help to encourage more interaction while looking more visually interesting than another line of text. I hope someone figures out how to hack this without too many mods to the core. :)
 
I spent an hour on this today and it looks like it's not very simple, hence probably why we haven't heard any simplistic solution. Based on my limited knowledge of Xenforo, it seems the only way to do this is to modify the "Core.php" file in the library/Xenforo/Template/Helper/ file.


Code:
/**
     * Returns an HTML string declaring who likes something
     *
     * @param integer Total number of likes
     * @param string Link to page showing all users who liked this content
     * @param integer Timestamp at which the visitor liked this content
     * @param array Array of up to 3 users who liked this content - user_id, username required.
     *
     * @return string
     */

/**
    * Returns an HTML string declaring who likes something
    *
    * @param integer Total number of likes
    * @param string Link to page showing all users who liked this content
    * @param integer Timestamp at which the visitor liked this content
    * @param array Array of up to 3 users who liked this content - user_id, username required.
    *
    * @return string
    */
   public static function helperLikesHtml($number, $likesLink, $likeDate = 0, array $users = array())
   {
     $number = intval($number);

     if (empty($users))
     {
       if ($number > 1)
       {
         return new XenForo_Phrase('likes_x_people_like_this', array(
           'likes' => self::numberFormat($number),
           'likesLink' => $likesLink
         ));
       }
       else
       {
         return new XenForo_Phrase('likes_1_person_likes_this', array(
           'likes' => self::numberFormat($number),
           'likesLink' => $likesLink
         ));
       }
     }

     $userCount = count($users);
     if ($userCount < 5 && $number > $userCount) // indicates some users are deleted
     {
       for ($i = 0; $i < $number; $i++)
       {
         if (empty($users[$i]))
         {
           $users[$i] = array(
             'user_id' => 0,
             'username' => new XenForo_Phrase('deleted_user_parentheses') // costs a query, but edge case
           );
         }
       }
     }

     if ($likeDate)
     {
       $youLikeThis = true;

       $visitorId = XenForo_Visitor::getUserId();
       foreach ($users AS $key => $user)
       {
         if ($user['user_id'] == $visitorId)
         {
           unset($users[$key]);
           break;
         }
       }

       $users = array_values($users);

       if (count($users) == 3)
       {
         unset($users[2]);
       }
     }
     else
     {
       $youLikeThis = false;
     }

     $user1 = $user2 = $user3 = '';

     if ($users[0])
     {
       $user1 = self::callHelper('username', array($users[0]));

       if ($users[1])
       {
         $user2 = self::callHelper('username', array($users[1]));

         if ($users[2])
         {
           $user3 = self::callHelper('username', array($users[2]));
         }
       }
     }

     $phraseParams = array(
       'user1' => $user1,
       'user2' => $user2,
       'user3' => $user3,
       'others' => self::numberFormat($number - 3),
       'likesLink' => $likesLink
     );

     switch ($number)
     {
       case 1: return new XenForo_Phrase(($youLikeThis
         ? 'likes_you_like_this'
         : 'likes_user1_likes_this'), $phraseParams, false);

       case 2: return new XenForo_Phrase(($youLikeThis
         ? 'likes_you_and_user1_like_this'
         : 'likes_user1_and_user2_like_this'), $phraseParams, false);

       case 3: return new XenForo_Phrase(($youLikeThis
         ? 'likes_you_user1_and_user2_like_this'
         : 'likes_user1_user2_and_user3_like_this'), $phraseParams, false);

       case 4: return new XenForo_Phrase(($youLikeThis
         ? 'likes_you_user1_user2_and_1_other_like_this'
         : 'likes_user1_user2_user3_and_1_other_like_this'), $phraseParams, false);

       default: return new XenForo_Phrase(($youLikeThis
         ? 'likes_you_user1_user2_and_x_others_like_this'
         : 'likes_user1_user2_user3_and_x_others_like_this'), $phraseParams, false);
     }
   }

It looks to involve modifying the code block that creates the string. I'm a PHP newb so I don't feel comfortable doing anything there, not to mention modifying CORE files.
 
Top Bottom