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

Using phrases

Discussion in 'XenForo Development Discussions' started by Benely, Apr 29, 2011.

  1. Benely

    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!
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

  3. ragtek

    ragtek Guest

    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(false0),
                
    'onlineUsers' => $onlineUsers,
                
    'boardTotals' => $boardTotals
            
    );
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Fair enough, but I didn't want to get into that level of complexity for a first timer ;)
     
  5. Benely

    Benely Member

    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?
     
  6. ragtek

    ragtek Guest

    You could do this with the template hooks!
     
  7. Benely

    Benely Member

    No idea how to do that :p

    Any links that might useful?
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

  9. ragtek

    ragtek Guest

    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^^
     

    Attached Files:

  10. Benely

    Benely Member

    I would like it in the footer, thank you!
     
  11. ragtek

    ragtek Guest

    there are several positions where it could be placed:p
    as in my attachment in post 9?
     
    Benely likes this.
  12. Benely

    Benely Member

    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.
     
  13. ragtek

    ragtek Guest

Share This Page