calorie
Active member
Show who is most liked of the members that are online now. Looks like this...
There are two ways to apply this add-on. First is to download the attached ZIP and follow the directions in the README file inside the ZIP archive. Alternatively, you can apply the add-on using the following instructions. Do not do both. Pick one way or the other. If you pick the ZIP, then you do not need to make manual edits (no phrase, template, or PHP file edits) but note that a new template called forum_list_most_liked_online_now is used instead of the default forum_list template.
So if you are a manual edit sort of person, this is what needs to be added/edited...
Add title most_liked_online_now with Most Liked Online Now phrase text.
Template...
Edit the forum_list template. Find:
After add:
PHP file...
Edit the /library/XenForo/ControllerPublic/Index.php file. Find:
After add:
Also find:
Replace with:
There are two ways to apply this add-on. First is to download the attached ZIP and follow the directions in the README file inside the ZIP archive. Alternatively, you can apply the add-on using the following instructions. Do not do both. Pick one way or the other. If you pick the ZIP, then you do not need to make manual edits (no phrase, template, or PHP file edits) but note that a new template called forum_list_most_liked_online_now is used instead of the default forum_list template.
So if you are a manual edit sort of person, this is what needs to be added/edited...
- 1 phrase to add
- 1 template to edit
- 1 PHP file to edit (two spots)
Add title most_liked_online_now with Most Liked Online Now phrase text.
Template...
Edit the forum_list template. Find:
Code:
<xen:include template="sidebar_online_users" />
After add:
Code:
<xen:if is="{$likedvisitors}">
<xen:require css="member_list.css" />
<div class="section staffOnline avatarList">
<div class="secondaryContent">
<h3>{xen:phrase most_liked_online_now}</h3>
<ul>
<xen:foreach loop="$likedvisitors" value="$user">
<li>
<xen:avatar user="$user" size="s" img="true" />
<a href="{xen:link members, $user}" class="username">{xen:helper richUserName, $user}</a>
<div class="muted">{xen:phrase likes}: {xen:raw $user.like_count}</div>
<div class="muted">{xen:helper userTitle, $user}</div>
</li>
</xen:foreach>
</ul>
</div>
</div>
</xen:if>
PHP file...
Edit the /library/XenForo/ControllerPublic/Index.php file. Find:
Code:
$onlineUsers = $sessionModel->getSessionActivityQuickList(
$visitor->toArray(),
array('cutOff' => array('>', $sessionModel->getOnlineStatusTimeout())),
($visitor['user_id'] ? $visitor->toArray() : null)
);
After add:
Code:
$likedVisitors = array();
if (!empty($onlineUsers))
{
$tempArray = array();
$tempCount = 0;
foreach ($onlineUsers['records'] AS $uniqueKey => $visitorInfo)
{
if ($visitorInfo['visible'] == 1 && $visitorInfo['like_count'] > 0)
{
$tempArray[$uniqueKey] = $visitorInfo['like_count'];
}
}
arsort($tempArray); // keys in descending order of likes
foreach ($tempArray AS $uniqueKey => $likeCount)
{
if ($tempCount == 5) // how many to show
{
break;
}
$likedVisitors[$uniqueKey] = $onlineUsers['records'][$uniqueKey];
$tempCount ++;
}
unset($tempArray);
}
Also find:
Code:
$viewParams = array(
'nodeList' => $this->_getNodeModel()->getNodeDataForListDisplay(false, 0),
'onlineUsers' => $onlineUsers,
'boardTotals' => $boardTotals
);
Replace with:
Code:
$viewParams = array(
'likedvisitors' => $likedVisitors,
'nodeList' => $this->_getNodeModel()->getNodeDataForListDisplay(false, 0),
'onlineUsers' => $onlineUsers,
'boardTotals' => $boardTotals
);