1. 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

Discussion in 'Styling and Customization Questions' started by CiaranT, Dec 29, 2014.

  1. CiaranT

    CiaranT Member

    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.
     
  2. Syndol

    Syndol Guest

    You would have to edit one PHP function (_getNotableMembers) and one template (member_list_item)
     
  3. CiaranT

    CiaranT Member

    Thanks. What do I need to add into these templates / functions?
     
  4. Syndol

    Syndol Guest

    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'
        
    ));
    }
     
    CiaranT likes this.
  5. Syndol

    Syndol Guest

    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.
     
  6. CiaranT

    CiaranT Member

    Basic question time. I am new to this. How do I go the above? Thanks.
     
  7. Syndol

    Syndol Guest

    The file would be located in your_installation/library/XenForo/ControllerPublic/Member.php
     
  8. CiaranT

    CiaranT Member

    Ok. thanks.
     
    Syndol likes this.

Share This Page