• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 Adding Time Last Online to Members List

#1
Hi,

In the "notable members" view, each member has number of messages, number of likes, number of trophy points.

How does one add "time last online" to the above list.

Thanks.
 
S

Syndol

Guest
#2
You would have to edit one PHP function (_getNotableMembers) and one template (member_list_item)
 
S

Syndol

Guest
#4
In function _getNotableMembers() in file XenForo_ControllerPublic_Member you will have to change
Code:
'join' => XenForo_Model_User::FETCH_USER_FULL,
to
Code:
'join' => XenForo_Model_User::FETCH_USER_FULL | XenForo_Model_User::FETCH_LAST_ACTIVITY,
and in template member_list_item you will have to add
HTML:
<xen:if is="{$user.effective_last_activity}"><br /><dt>{xen:phrase last_activity}:</dt> <dd>{xen:datetime $user.effective_last_activity, 'html'}</dd></xen:if>
right after
HTML:
<dt>{xen:phrase trophy_points}:</dt> <dd title="{xen:phrase trophy_points}">{xen:number $user.trophy_points}</dd>
Note that to also add the last activity to the "Staff" tab, you will also have to edit function actionIndex()
change
PHP:
if ($type == 'staff')
{
    $users = $userModel->getUsers(array('is_staff' => true), array(
        'join' => XenForo_Model_User::FETCH_USER_FULL,
        'order' => 'username'
    ));
}
to
PHP:
if ($type == 'staff')
{
    $users = $userModel->getUsers(array('is_staff' => true), array(
        'join' => XenForo_Model_User::FETCH_USER_FULL | XenForo_Model_User::FETCH_LAST_ACTIVITY,
        'order' => 'username'
    ));
}
 
S

Syndol

Guest
#5
You could turn this into an add-on of course, but that would mean adding an extra query in order to fetch the effective last activity for the resulting users.
 
S

Syndol

Guest
#7
The file would be located in your_installation/library/XenForo/ControllerPublic/Member.php