Using phrases

Benely

Member
Hello,

This is my first time working with Xenforo and I have a question regarding phrases. I am attempting to add to the footer the following phrase:

{xen:phrase online_now_x_members_y_guests_z, 'total={xen:number $onlineUsers.total}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}

But I get: Members Online 0 (0 members, 0 vistors)

Is this something to do with phrases only being accessible in certain templates? Thanks for your help!
 
Not 100% true brogan;)

Phrases CAN contain variables, BUT they need to be available in the template!

The index controllers adds the online users to the viewparams, that's why they are available in the view!
PHP:
$onlineUsers = $sessionModel->getSessionActivityQuickList(
            $visitor->toArray(),
            array('cutOff' => array('>', $sessionModel->getOnlineStatusTimeout())),
            ($visitor['user_id'] ? $visitor->toArray() : null)
        );

        $viewParams = array(
            'nodeList' => $this->_getNodeModel()->getNodeDataForListDisplay(false, 0),
            'onlineUsers' => $onlineUsers,
            'boardTotals' => $boardTotals
        );
 
Fair enough, but I didn't want to get into that level of complexity for a first timer ;)
 
I kind of get the idea of viewparams, is there a way to globally add onlineUsers to every view param? As I'm attempting to put it in the footer, unless the footer has its own viewparams?
 
I kind of get the idea of viewparams, is there a way to globally add onlineUsers to every view param? As I'm attempting to put it in the footer, unless the footer has its own viewparams?
You could do this with the template hooks!
 
Where do you want to display them?
I've coded a quick (and dirty because of the overhead) add-on for this:) Just need the position where you exactly want it^^
 

Attachments

  • footer.webp
    footer.webp
    7.3 KB · Views: 5
Oh sorry didn't see the attachment, well I am actually in the progress of skinning my forum so it looks nothing like that. But I guess its similar to your position.
 
Top Bottom