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

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

Brogan

XenForo moderator
Staff member
#2
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.
 

Brogan

XenForo moderator
Staff member
#4
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.
 

xf_phantom

Well-known member
#6
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:

xf_phantom

Well-known member
#8
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;)
 

Jeremy

Well-known member
#9
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.
 

Stuart Wright

Well-known member
#12
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:

xf_phantom

Well-known member
#13
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
 

xf_phantom

Well-known member
#17
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>
 

Stuart Wright

Well-known member
#19
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>
 

borbole

Well-known member
#20
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;