![]() |
Displaying forumstats in a sidebar block
Hello. I'm trying to move the Forum Statistics from What's Going On into a forum block. I read that it was possible to put the code in a template, and then just register the template in a PHP block. I'm there, but how to I access the variables in the template?
Here's my code Created new template called 'forumhome_forumstats' Code:
<dl> Code:
$templater = vB_Template::create('forumhome_forumstats'); Thank you |
Your php code need to include code to get and/or calculate whatever values you display. If you look at the file forum.php, you can find the code that calculates the values. I believe it depends on having 'userstats' in the $specialtemps array (near the top of the file). You would probably need to have something in your code to fetch it if it doesn't exist, so maybe something like:
Code:
global $vbulletin; |
For some reason that code above breaks, and forumhome is just a white page.
|
Then check your error_logs (if you don't know where they are, ask your host) and see what is there. But, you can't just use that code - you have to write a whole bunch of your own to go with it if you want the stats to display.
|
Quote:
Edit: Just wanted to point out that $vbulletin->datastore->fetch(array('name')) breaks on two boards I work with (when using it in forum blocks). |
Sorry about that, I hadn't tried that code at all, and there was a missing close paren which I've fixed, and it also needed a "global".
But thinking about it a little more, the forum block only appears on the home page which already loads the userstats, so you probably don't really need that code (unless you use a mod that puts the sidebar on other pages). You would need to declare $vbulletin as global (as in the first line of code I added above). |
Got it working. All I was missing was the global. I had implied that was included automatically. Sorry about that...but thank you for the help! :)
|
All times are GMT. The time now is 06:49 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|