No announcement yet.

$totalonline in template "header"

  • Filter
  • Time
  • Show
Clear All
new posts

  • $totalonline in template "header"


    I would like to show the total number of visitors in the template "header". This variable is called $totalonline ...

    But it is only avialable in the template "forumhome", because this variable is given only in index.php ...

    How may I display the total number of visitors in the template "header"?

    Greetings, The Professor!

  • #2
    Move the code from the index.php file to global.php above where the header gets parsed.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API - Full / Mobile
    Vote for your favorite feature requests and the bugs you want to see fixed.


    • #3

      can you please explain a little?

      I read this sentence already in the templates subforum and
      still couldn't figure out how to do that...

      Thanks a bunch,

      P.S.: I would be more happy if this could be done without modifying the code but by tweaking the templates...
      German Windows Server & IT Pro Community dedicated to Windows Client & Server Systems. MVPs inside


      • #4
        The problem is that the $totalonline variable isn't available in the header template, so to do this the code has to be moved the the index.php (where its normally used) to the global.php (so thats its available to any template)

        Its fairly easy, this is how I think you should to do it:

        1. Make backups of index.php and global.php, and a database backup just incase
        2. Open index.php and find:
          $maxusers=explode(" ", gettemplate('maxloggedin',0,0));
          if ((int)$maxusers[0] <= $totalonline) {
            $time = time();
            $maxloggedin = "$totalonline " . $time;
            $DB_site->query("UPDATE template SET template='$maxloggedin' WHERE title='maxloggedin'");
            $maxusers[0] = $totalonline;
            $maxusers[1] = $time;
          $recordusers = $maxusers[0];
          $recorddate = vbdate($dateformat,$maxusers[1]);
          $recordtime = vbdate($timeformat,$maxusers[1]);
          eval("\$loggedinusers = \"".gettemplate('forumhome_loggedinusers')."\";");
        3. Cut that and paste into global.php under:
        4. Save, and upload the files

        You should now be able tu use the $totalonline variable in your header.

        Works for me

        Comments or critisim warmly welcomed
        HP DL-380 G6, 2x E5520, 28GB RAM, 4x300GB SAS, VMWare ESXi
        Unreal Tournament : Assault forums - irc:// -


        • #5
          does it matter where we paste a defing varible in the global.hph file.
          My FFXI Linkshell Website


          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.