Adding a tab to Members

Myke623

Well-known member
My goal is to to add a new tab to the Members page that list members based on some yet-to-be-defined criteria.

In looking around for existing resources that would help me develop this I found:

Creating an add-on to insert tabs in profile page (using hooks)

which is pretty close to what I need, except that it's on the profile page and not members and figure it should be straightforward enough to adapt. However, the other main issue is that it relies on the now deprecated template hook system, so I'd need to use the Template Modification feature introduced in 1.2 instead:

Template Modifications and Comparison

Not having any prior experience in template hooks/modifications, I'd appreciate some advice in how I would go about this development.

What are the core ingredients I need? Are there any existing free resources already doing this that I could learn from? Is it trivial enough to augment the template hook tutorial to use Template Modifications instead?

Thanks in advance.
 
From memory when I added it to my add-on, the basic steps are:
  • Listeners for member controller and your user model
  • Controller function extending member
  • Model
  • Template for the tab
  • Template modification to add the template to the notable members page
 
I can help if you're still looking?
I am by no way or means a developer, but I have done the same thing within the last few days - and actually found this whilst trying to find how to add the content afterwards.
On notable members, under members page, I have managed to create a tab and even add info in there from members' data such as name, avatar etc etc..
However, my stumbling block now, is adjusting the content and names are A-Z so it only lists about 10-15 members starting at A.

So I can help but am stuck myself at that point if it is any use to you?
I know it's an old thread, but you may still be trying to do this?
Again I am in no way a dev, (or expert in XF) just trying to accomplish something myself too.
 
I can help if you're still looking?
To be honest, I kind of shelved my project due to other priorities but I have some spare time now so I might look into this again.

After doing a quick search to see if anyone has 'freely' developed such a feature (no luck I'm afraid), it looks like you tried to achieve the additional members tab via direct code and template edits (Add another "notable member" tab)?

My preference is to develop an addon, so I'll report back if I manage to complete it!
 
I've got a basic addon working that adds a tab to Notable Members, and simply replicates the 'most messages' tab in functionality. It listens to the load_class_controller event, and extends XenForo_ControllerPublic_Member with my own Member controller.

In my Member controller:

PHP:
protected function _getNotableMembers($type, $limit)
    {
        $result = parent::_getNotableMembers($type, $limit);
      
        if (!$result && $type=='foo')
        {
            $userModel = $this->_getUserModel();
  
            $notableCriteria = array(
                    'is_banned' => 0
            );
          
            $typeMap = array(
                    'foo' => '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' => 'desc'
            )), $typeMap[$type]);
        }
        else
        {
            return $result;
        }
  
    }

With a template modification on 'member_notable' in place, this works as expected.

Now I wish to expand on this by specifying both the filter and the ordering based on fields not found in table xf_user but say, in table xf_user_profile, or a custom table. How can I go about this? I know that @Brogan suggested that I needed a listener and model for the user but I'm not exactly sure of the implementation.
 
So the FETCH_USER_FULL constant ensures that additional data is queried in getUsers() which includes the user profile, and that's partly what I need.

But I can't specify these other fields in the profile (say 'location') as either the filter condition and/or for ordering. This is due to user model's prepareUserConditions() and prepareUserOrderOptions() only working on specific user fields.

I'm still finding my feet with OOP, but is the idea that I extend the User model with my own, and add my own version of prepareUserConditions(), etc that works with my field(s) of interest?
 
I'm revisiting this after a long hiatus.

I'm trying to add a new tab to the Members page that orders by location and eventually, I want to add filters on this to enable searching for members in certain areas. This feature will require users to opt-in and will facilitate match making for particular games.

Anyway, when I try to specify, say, 'location' instead of 'message_count' for the ordering:

PHP:
            $typeMap = array(
                    'challenger' => 'location',
            );

I get the following error:
Template Errors: member_notable
  1. number_format() expects parameter 1 to be double, string given in path\xf\library\XenForo\Locale.php, line 720
  2. number_format() expects parameter 1 to be double, string given in path\xf\library\XenForo\Locale.php, line 720

Am I taking the wrong approach? I'd appreciate any suggestions.
 
Back
Top Bottom