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

Add another "notable member" tab

#45
I am only getting a hand full of members. I have over 100 Server admins and it is not even displaying 10% of them. Below is screenshot and code. I want to be able to display all my server admins jsut like the staff is displayed, not by post count or top 10, but all of them and have it show the same as it shows for my forum staff. Forum staff screenshot is below also
Template:
Code:
<xen:title>{xen:phrase notable_members}</xen:title>

<xen:container var="$head.canonical">
    <link rel="canonical" href="{xen:link 'canonical:members'}" /></xen:container>

<xen:require css="member_list.css" />
<xen:require css="xenforo_member_list_item.css" />
  
<xen:if is="{$userNotFound}">
    <div class="importantMessage">{xen:phrase specified_member_cannot_be_found_enter_entire_name}</div>
</xen:if>

<ul class="tabs">
    <li class="{xen:if '{$type} == "messages"', active}"><a href="{xen:link members}">{xen:phrase most_messages}</a></li>
    <li class="{xen:if '{$type} == "likes"', active}"><a href="{xen:link members, '', 'type=likes'}">{xen:phrase most_likes}</a></li>
    <li class="{xen:if '{$type} == "points"', active}"><a href="{xen:link members, '', 'type=points'}">{xen:phrase most_points}</a></li>
    <li class="{xen:if '{$type} == "staff"', active}"><a href="{xen:link members, '', 'type=staff'}">{xen:phrase staff_members}</a></li>
    <li class="{xen:if '{$type} == "vip"', active}"><a href="{xen:link members, '', 'type=vip'}">Server Admins</a></li>
</ul>

<div class="section">
    <ol class="memberList">
        <xen:foreach loop="$users" value="$user">
            <xen:include template="member_list_item">
                <xen:set var="$noOverlay">1</xen:set>
                <xen:set var="$extraTemplate"><xen:if is="{$bigKey}"><span class="bigNumber">{xen:number {$user.{$bigKey}}}</span></xen:if></xen:set>
            </xen:include>
        </xen:foreach>
    </ol>
</div>

<xen:sidebar>
    <div class="section">
        <form action="{xen:link members}" method="post" class="secondaryContent findMember">
            <h3><a href="{xen:link online}" title="{xen:phrase see_all_online_users}">{xen:phrase find_member}</a></h3>
              
            <input type="search" name="username" placeholder="{xen:phrase name}..." results="0" class="textCtrl AutoComplete" data-autoSubmit="true" />
            <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
        </form>
    </div>

    <xen:if is="{$birthdays}">
        <div class="section">
            <div class="secondaryContent avatarHeap">
                <h3>{xen:phrase todays_birthdays}</h3>
              
                <ol>
                <xen:foreach loop="$birthdays" value="$user">
                    <li><xen:avatar user="$user" size="s" text="{$user.username}" class="Tooltip" data-tipclass="flipped" title="{$user.username}" /></li>
                </xen:foreach>
                </ol>
            </div>
        </div>
    </xen:if>
  
    <xen:if is="{$latestUsers}">
        <div class="section newestMembers">
            <div class="secondaryContent avatarHeap">
                <h3>{xen:phrase newest_members}</h3>
              
                <ol>
                    <xen:foreach loop="$latestUsers" value="$user">
                        <li><xen:avatar user="$user" size="s" text="{$user.username} ({xen:datetime $user.register_date})" class="Tooltip" data-tipclass="flipped" title="{$user.username}, {xen:phrase joined}: {xen:datetime $user.register_date}" /></li>
                    </xen:foreach>
                </ol>
            </div>
        </div>
    </xen:if>
  
    <xen:if is="{$xenOptions.facebookAppId} AND {$xenOptions.facebookFacepile}">
        <div class="fbWidgetBlock">
            <xen:container var="$facebookSdk">1</xen:container>
            <div class="section">
                <fb:facepile width="@sidebar.width" size="small" colorscheme="@fbColorScheme"></fb:facepile>
            </div>
        </div>
    </xen:if>
</xen:sidebar>
PHP:
Code:
protected function _getNotableMembers($type, $limit)
    {
        $userModel = $this->_getUserModel();

        $notableCriteria = array(
            'is_banned' => 0
        );

        if ($type == 'vip')
        {
            $notableCriteria['secondary_group_ids'] = array(7,8);
        }

        $typeMap = array(
            'messages' => 'message_count',
            'likes' => 'like_count',
            'points' => 'trophy_points',
            'vip' => 'message_count'
        );

        if (!isset($typeMap[$type]))
        {
            return false;
        }

 

Glockie

Well-known member
#48
Amendment in blue:

library/XenForo/ControllerPublic/Member.php

Code:
    protected function _getNotableMembers($type, $limit)
    {
        $userModel = $this->_getUserModel();

        $notableCriteria = array(
            'is_banned' => 0
        );

        if ($type == 'vip')
        {
            $notableCriteria['secondary_group_ids'] = array(3);
        }

        $typeMap = array(
            'messages' => 'message_count',
            'likes' => 'like_count',
            'points' => 'trophy_points',
            'vip' => 'message_count'
        );

        if (!isset($typeMap[$type]))
        {
            return false;
        }

        return array($userModel->getUsers($notableCriteria, array(
            'join' => XenForo_Model_User::FETCH_USER_FULL,
            'limit' => $limit,
            'order' => $typeMap[$type],
            'direction' => ($type == 'vip' ? 'asc' : 'desc')
        )), $typeMap[$type]);
    }
Hello @Jake Bunce - is it possible to list new members? as in latest registered members?
That's something I would love to have.. The code you've written there is almost there for me, I can see it, but just don't know the rest..
This works lovely, thank you!
 

batpool52!

Well-known member
#49
Code:
    protected function _getNotableMembers($type, $limit)
    {
        $userModel = $this->_getUserModel();

        $notableCriteria = array(
            'is_banned' => 0
        );

        $typeMap = array(
            'messages' => 'message_count',
            'likes' => 'like_count',
            'points' => 'trophy_points',
            'latest' => 'join_date'
        );

        if (!isset($typeMap[$type]))
        {
            return false;
        }

        return array($userModel->getUsers($notableCriteria, array(
            'join' => XenForo_Model_User::FETCH_USER_FULL,
            'limit' => $limit,
            'order' => $typeMap[$type],
            'direction' => ($type == 'latest' ? 'asc' : 'desc')
        )), $typeMap[$type]);
    }
^ That should work but haven't tested it.
 

Glockie

Well-known member
#51
Okay a slight issue, it does work but is going through the memberlist alphabetically and goes so far then stops..
Grr these things are sent to try us.

Code:
        if ($type == 'latest')
        {
            $notableCriteria['secondary_group_ids'] = array(3,5);
        }
       
        $typeMap = array(
            'messages' => 'message_count',
            'likes' => 'like_count',
            'points' => 'trophy_points',
            'latest' => 'join_date'
        );

        if (!isset($typeMap[$type]))
        {
            return false;
        }

        $field = $typeMap[$type];

        $notableCriteria[$field] = array('>', 0);

        return array($userModel->getUsers($notableCriteria, array(
            'join' => XenForo_Model_User::FETCH_USER_FULL,
            'limit' => $limit,
            'order' => $field,
            'direction' => ($type == 'latest' ? 'asc' : 'desc')
        )), $typeMap[$type]);
    }
Have I done something wrong?
The numbers are something else I can look into (like page 1,2,3 etc) but I need the latest registered and it's doing all and any, and from a-z haha
I hope you can help, or just point out where my mistake is?
Many thanks and sorry to trouble anyone.
 
#56
Is it possible to add more than one tab to notable members?
Code:
if ($type == 'dcm')
        {
            $notableCriteria['secondary_group_ids'] = array(9);
        }
      
        if ($type == 'freund')
        {
            $notableCriteria['secondary_group_ids'] = array(15);
        }
      
        if ($type == 'hod')
        {
            $notableCriteria['secondary_group_ids'] = array(11);
        }

        $typeMap = array(
            'messages' => 'message_count',
            'likes' => 'like_count',
            'points' => 'trophy_points',
            'dcm' => 'usernames',
            'freund' => 'usernames',
            'hod' => 'usernames'
        );
This is my Code, but only the last if statement will be work. The other give a blank page under there tabs ..
anyone know how to do this still?
 

CarpCharacin

Well-known member
#57
@Jake Bunce I am getting this error
Parse error: syntax error, unexpected ')', expecting function (T_FUNCTION) in /home/public_html/library/XenForo/ControllerPublic/Member.php on line 131
I want it to be bod instead of vip for board of directors. this is code
PHP:
<?php

    protected function _getNotableMembers($type, $limit)
    {
        $userModel = $this->_getUserModel();

        $notableCriteria = array(
            'is_banned' => 0
        );

        if ($type == 'bod')
        {
            $notableCriteria['secondary_group_ids'] = array(10);
        }

        $typeMap = array(
            'messages' => 'message_count',
            'likes' => 'like_count',
            'points' => 'trophy_points',
            'direction' => ($type == 'bod' ? 'asc' : 'desc')
        );