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

XF 1.4 PHP Help needed!

Discussion in 'XenForo Questions and Support' started by Tony008, Nov 21, 2014.

  1. Tony008

    Tony008 Member

    Hello.

    Can someone tell me please how to count this two time?

    guests={xen:number $onlineUsers.guests}

    or also to show +22 or + 50

    Any idea?

    I have made this in vbulletin before some time but no idea how.


    Thank you!
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    You can use xen:calc to perform mathematical operations in templates.
     
    Tony008 likes this.
  3. Tony008

    Tony008 Member

    Hey Brogan.
    Any example how to do with this: guests={xen:number $onlineUsers.guests}
     
  4. Tony008

    Tony008 Member

    guests={xen:calc 50+ $onlineUsers.guests} ??
     
  5. Brogan

    Brogan XenForo Moderator Staff Member

    {xen:calc "{$onlineUsers.guests} + 50"}
     
    Tony008 likes this.
  6. Tony008

    Tony008 Member

    wont work. Should I wait untill the cronjob updates or?
     
  7. Brogan

    Brogan XenForo Moderator Staff Member

    Last edited: Nov 21, 2014
    Tony008 likes this.
  8. Tony008

    Tony008 Member

    No thats not related with that thread.

    Am trying to increase the guests number in index.

    I want to show +50 guests.

    The code is from this template:
    sidebar_online_users
     
  9. Brogan

    Brogan XenForo Moderator Staff Member

    It works.

    I have just tested and confirmed.

    upload_2014-11-21_19-46-33.png
     
    Tony008 likes this.
  10. Tony008

    Tony008 Member

    I have replaced this:

    "{xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number $onlineUsers.total}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}', 'robots={xen:number $onlineUsers.robots}'}"

    With this:

    {xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number $onlineUsers.total}', 'members={xen:number $onlineUsers.members}', 'guests={xen:calc "{$onlineUsers.guests} + 50"}', 'robots={xen:number $onlineUsers.robots}'}


    And nothing showing :(
    Whats am doing wrong?
     
  11. Tony008

    Tony008 Member

    Brogan you was right! Its working. Am usinf the framework widget and thats why was not showing the result. I have edited the framework widget and works! Thank you again!
     
  12. Brogan

    Brogan XenForo Moderator Staff Member

    Glad to hear it's sorted.

    It's worth mentioning any add-ons you are using as they can have an impact (as you've discovered).
     
  13. Tony008

    Tony008 Member

    Yes will add it.
    One more thing if you have time to answer me:

    Id like to add the username with id 2 to show in this line:

    This is from the sidebar_online template.

    Now as it is, it shows the users that are online. Id like to add additional user lats say the user with id nr.2

    How to do it?
     

Share This Page