How do I create a list of members in particular usergroups on a page node?

If you want to have separate tabs and pull lots of statistics related to each advertiser then it will require a php callback and some custom code.
 
Don't need the tabs Brogan, just a single (standard) list of members from a couple of usergroups with some pretty HTML top and bottom.
 
How will the members be selected?
If you're doing it manually then it's just a case of constructing the HTML and CSS depending on how you want to present the content.

For the most part you can use core classes and structure, assuming you want similar appearance to other pages.
 
You could also use
PHP:
$criteria = array(
  'secondary_group_ids' => array(1,2)
  );
$options = array(
       'join' => XenForo_Model_User::FETCH_USER_FULL,
       'order' => 'username'
     ));
  $users = $this->getModelFromCache('XenForo_Model_User')->getUsers($criteria, $options);
 
Last edited:
yes, my above code into the callback.

You'll have to replace $this from $this->getModelFromCache('XenForo_Model_User')
with the variable name you're using for the controller parameter;)
 
You will never be able to run raw PHP in templates. Unless its xen:* syntax or it is a whitelisted function, you won't be able to run them.
 
You could also use
PHP:
$criteria = array(
  'secondary_group_ids' => array(1,2)
  );
$options = array(
       'join' => XenForo_Model_User::FETCH_USER_FULL,
       'order' => 'username'
     ));
  $users = $this->getModelFromCache('XenForo_Model_User')->getUsers($criteria, $options);
I'm getting an error. What do I put instead of $this?
PHP:
class AVForums_AdvertiserList_ControllerPublic_AdvertiserList
{
    public static function getAdvertiserList(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)
    {


    $criteria = array(
        'secondary_group_ids' => array(10,13,16)
      );
    $options = array(
        'join' => XenForo_Model_User::FETCH_USER_FULL,
        'order' => 'username'
    );
    $users = $this->getModelFromCache('XenForo_Model_User')->getUsers($criteria, $options);

    print_r($users);
    $pageout = "";
    $response->params['pageout'] = $pageout;
       
    }
}
 
Last edited:
I'm getting an error. What do I put instead of $this?
PHP:
class AVForums_AdvertiserList_ControllerPublic_AdvertiserList
{
    public static function getAdvertiserList(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)
    {


    $criteria = array(
        'secondary_group_ids' => array(10,13,16)
      );
    $options = array(
        'join' => XenForo_Model_User::FETCH_USER_FULL,
        'order' => 'username'
    );
    $users = $this->getModelFromCache('XenForo_Model_User')->getUsers($criteria, $options);

    print_r($users);
    $pageout = "";
    $response->params['pageout'] = $pageout;
      
    }
}
Post your code:D
 
PHP:
$controller->getModelFromCache('XenForo_Model_User'
instead of
PHP:
$this->getModelFromCache('XenForo_Model_User'
 
Lovely, thank you :)
Is there a template I can use in the php script to format each user in a row like in the notable members list please?
 
Code:
<ol class="section memberList">
   <xen:foreach loop="$users" value="$user">
     <xen:include template="member_list_item">
       <xen:set var="$noOverlay">1</xen:set>
     </xen:include>
   </xen:foreach>
</ol>
 
I have created control over the display in my own page though matthew and it's coming along, thanks everyone.
I've created a sidebar and put the users online and stats boxes in it, but they both contain null data.
I'm guessing I have to call getInstance() or something to populate them.
I looked around but couldn't find an answer.
HTML:
<xen:sidebar>
    <xen:edithint template="sidebar.css" />
    <xen:hook name="forum_list_sidebar">
    </xen:hook>
    <xen:include template="sidebar_online_users" />

    <div class="section">
        <div class="secondaryContent statsList" id="boardStats">
            <h3>{xen:phrase forum_statistics}</h3>
            <div class="pairsJustified">
                <dl class="discussionCount"><dt>{xen:phrase discussions}:</dt>
                    <dd>{xen:number $boardTotals.discussions}</dd></dl>
                <dl class="messageCount"><dt>{xen:phrase messages}:</dt>
                    <dd>{xen:number $boardTotals.messages}</dd></dl>
                <dl class="memberCount"><dt>{xen:phrase members}:</dt>
                    <dd>{xen:number $boardTotals.users}</dd></dl>
                <dl><dt>{xen:phrase latest_member}:</dt>
                    <dd><a href="{xen:link members, $boardTotals.latestUser}" class="username">{$boardTotals.latestUser.username}</a></dd></dl>
            </div>
        </div>
    </div>
</xen:sidebar>
 
In your php file add this code:

PHP:
$visitor = XenForo_Visitor::getInstance();

$sessionModel = $this->getModelFromCache('XenForo_Model_Session');

$onlineUsers = $sessionModel->getSessionActivityQuickList(
            $visitor->toArray(),
            array('cutOff' => array('>', $sessionModel->getOnlineStatusTimeout())),
            ($visitor['user_id'] ? $visitor->toArray() : null)
        );
    
        $boardTotals = $this->getModelFromCache('XenForo_Model_DataRegistry')->get('boardTotals');
        if (!$boardTotals)
        {
            $boardTotals = $this->getModelFromCache('XenForo_Model_Counters')->rebuildBoardTotalsCounter();
        }

Then register the $onlineUsers and $boardTotals vars for use in your custom template.

PHP:
$response->params['onlineUsers'] = $onlineUsers;
$response->params['boardTotals'] = $boardTotals;
 
Top Bottom