Announcement

Collapse
No announcement yet.

$totalthreads, $totalposts, $numbermembers aren't calling correctly in header

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • $totalthreads, $totalposts, $numbermembers aren't calling correctly in header

    Whenever I try and call either

    $totalthreads
    $totalposts
    $numbermembers

    inside the header they aren't showing up. Any ideas why?

  • #2
    Those variables only work in the FORUMHOME template. Custom code is required to get them working in the header. For help with this I recommend you post on www.vbulletin.org.

    Comment


    • #3
      what code inside forumhome.php allows those variables to work?

      Comment


      • #4
        Code:
        // ### BOARD STATISTICS #################################################
        
        // get total threads & posts from the forumcache
        $totalthreads = 0;
        $totalposts = 0;
        if (is_array($vbulletin->forumcache))
        {
        	foreach ($vbulletin->forumcache AS $forum)
        	{
        		$totalthreads += $forum['threadcount'];
        		$totalposts += $forum['replycount'];
        	}
        }
        $totalthreads = vb_number_format($totalthreads);
        $totalposts = vb_number_format($totalposts);
        
        // get total members and newest member from template
        $numbermembers = vb_number_format($vbulletin->userstats['numbermembers']);
        $newusername = $vbulletin->userstats['newusername'];
        $newuserid = $vbulletin->userstats['newuserid'];
        $activemembers = vb_number_format($vbulletin->userstats['activemembers']);
        $show['activemembers'] = ($vbulletin->options['activememberdays'] > 0 AND ($vbulletin->options['activememberoptions'] & 2)) ? true : false;

        Comment


        • #5
          Just for anyone searching here is what I did to solve the problem.

          Go to AdminCP > Plugins
          Add a new plugin using global_start. Use this code.

          Code:
          // forum stats start 
          $numbersmembers = $db->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM user"); 
          $numbermembers= number_format($numbersmembers['users']); 
              $totalthreads = $db->query_first("SELECT COUNT(threadid) FROM " . TABLE_PREFIX . "thread");
          $totalthreads = implode(",",$totalthreads);
              $totalposts = $db->query_first("SELECT COUNT(postid) FROM " . TABLE_PREFIX . "post");
          $totalposts = implode(",",$totalposts1); 
          // forum stats end
          This will allow the above 3 variables to work on any VB page.
          Jake, is your above code any more efficient if I were to add that to the global_start?

          Comment


          • #6
            Your code runs new queries. The default code accesses the cached values for those counts. The cache is better.

            Comment


            • #7
              Then can I simply replace your code with what I have in the plugin I have created using the global_start?

              Comment


              • #8
                Probably. If you need help with custom code like this then you should post on www.vbulletin.org.

                Comment


                • #9
                  I have Jake, and the above code was what I was given.
                  I'd also like to say that your programming team should just build those variables to be global.

                  There are dozens of threads on .org concerning trying to get those stats somewhere other than forumhome.

                  EDIT: BTW Jake, your code doesn't work when included in the global_start
                  Last edited by cyr0n_k0r; Thu 27 Dec '07, 12:08am.

                  Comment


                  • #10
                    I used the code that cyr0n_k0r mentioned in post #7.
                    It seemed to work on all pages, but on the pages with vBulletin messages (like after the logout) the stats disappear.
                    Is there a possibility to solve this issue?

                    Comment


                    • #11
                      I'm sorry but we do not provide official support for custom coding. However you can try asking for this kind of help over at the vB mod site: http://www.vbulletin.org/forum/
                      Kerry-Anne :)

                      Twitter Blog

                      www.peterska2.com www.worldnewszone.com www.popularusenetgroups.com www.superclickers.co.uk www.forumsforchrist.com www.browsergameplanet.com

                      Comment

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