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

Using phrases

#1
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!
 
R

ragtek

Guest
#3
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
        );
 
#5
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?
 
R

ragtek

Guest
#6
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!
 
R

ragtek

Guest
#9
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

#12
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.