miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

Displaying total count of users and latest registered member on the first page

 
Author Anonymous
Guest
#1 | Posted: 22 Jul 2007 15:59 
I was wondering how to add more info to the whos online add-on. I want to add total registered users under the first column and Welcome, newest member <user> in the other column. I see the code that gets this info in the stats template stats.html but when I copy it to addon_whosonline.php in the bottom table section the info won't come up?

Author Paul
Lead Developer 
#2 | Posted: 24 Jul 2007 11:49 
I think who's online addon is not involved in this information's displaying at all.

What you need to do is just to generate 2 new variables in bb_plugins.php which use 2 additional mySQL requests (which will load up your database without a lot of sense).

Kind of:

/* 1st page stats */

if($action==''){

if($numUsersDb=db_simpleSelect(0,$Tu,'count(*)')) $numUsers=$numUsersDb[0]-1; else $numUsers='N/A';

if($row=db_simpleSelect(0,$Tu,"{$dbUserId}, {$dbUserSheme['username'][1]}", '', '', '', "{$dbUserId} DESC", 1)) {
$lastUserDbLnk="Welcome, newest member <a href=\"https://www.minibb.com/forums/{$indexphp}action=userinfo&amp;user={$row[0]}\">{$row[1]}</a>";
} else {
$lastUserDbLnk='';
}

}

/* --1st page stats */
Then put {$numUsers} and {$lastUserDbLnk} in templates/main_footer.html wherever you would like...

Author Anonymous
Guest
#3 | Posted: 24 Jul 2007 12:33 
Theres no way of showing that info in addon_whosonline.php block? I added the variables but they don't show up? they do when i put them in the footer

Author Paul
Lead Developer 
#4 | Posted: 24 Jul 2007 15:04 
If you would like to display them in "who's online" block, then put this code before inclusion of this addon. You also need to modify {$whosOnline} of the addon_whosonline.php and put these variables there the way you would like to see them on the page.

I would not recommend though to display such information on every forum page, it makes no sense, but requests to database take a lot of resources...

Author Anonymous
Guest
#5 | Posted: 24 Jul 2007 18:25 
"put this code before inclusion of this addon." which file? bb_plugins.php? I understand what you mean about resources, what do I have to to to just use it in the front page footer? Also, on the front page, it always says I have one more registered user than any other page, which is weird?

Front page: Registered members:69
Now stats page: Total Number of Signed Up Users » 68

Author Paul
Lead Developer 
#6 | Posted: 25 Jul 2007 02:47 
which file? bb_plugins.php

- yes. I don't other place where who's online addon is included ;-)

what do I have to to to just use it in the front page footer

- I have modified the code above so it follow the $action=='' condition which means execution only on the first page.

it always says I have one more registered user than any other page, which is weird

- sure, I forgot to minus one user as it's done for the statistics (admin is not counted). I've fixed the code also regarding this. Please check.

Author Anonymous
Guest
#7 | Posted: 25 Jul 2007 08:45 
I got it now, How do I add Total Members: to the $numUsers variable? I added it to the addon_whosonline.php file but then if your not on the front page it says Total Members: and no number.

if($numUsersDb=db_simpleSelect(0,$Tu,'count(*)')) $numUsers=$numUsersDb[0]-1; else $numUsers='N/A';

Author Paul
Lead Developer 
#8 | Posted: 25 Jul 2007 10:27 
if your not on the front page it says Total Members: and no number

That's logical... if($action==''){ condition includes both of the SQL requests... so for enabling on all pages you need to move it one line below ;-)

Author Anonymous
Guest
#9 | Posted: 25 Jul 2007 11:06 
Well I thought everything was good. I am getting errors in my error_log. It still works though, every still shows up?

PHP Notice: Undefined variable: lastUserDbLnk in /srv/www/htdocs/forum/addon_whosonline.php on line 125
PHP Notice: Undefined variable: numUsers in /srv/www/htdocs/forum/addon_whosonline.php on line 128

Lines in addon_whosonline.php

Line 125: <span class="txtSm">{$l_whosOnline} {$l_guestsOnline} - {$guestsCount}<br />{$l_loggedOnline} - {$registeredCount} {$registeredList}<br />{$lastUserDbLnk}</span>

Line 128:
<span class="txtSm">{$l_onlineRecord} {$recTotal} [{$recDate}]<br />{$l_guestsOnline} - {$w_record[1]} / {$l_loggedOnline} - {$w_record[2]}<br />{$numUsers}</span>

Author Paul
Lead Developer 
#10 | Posted: 27 Jul 2007 07:09 
Are you familiar with PHP at all? ;-)
If variable seems undefined, it is good to define an empty value somewhere. I've fixed my code so it defines first:

$numUsers='';
$lastUserDbLnk='';

Author Sergeusz
Partaker
#11 | Posted: 1 May 2008 14:20 
I include this code in main_footer.html and it looks great

<table class="forumsmb">
<tr>
<td class="caption5">
<span class="txtSm">{$numUsers}<br><a href="https://www.minibb.com/forums/{$indexphp}action=members">Members list</a></span>
</td>
<td class="caption5" style="text-align:right">
<span class="txtSm">{$lastUserDbLnk}</span>
</td>
</tr>
</table>

But I want this table disappear on all the other pages except the main, because {$numUsers} and {$lastUserDbLnk} appear only on the main page while remains of the table are still on other pages - it's not very perfect. Can you suggest anything? May be I need to create this table in bb_plugins where is situated /* 1st page stats */ code?

Author Paul
Lead Developer 
#12 | Posted: 2 May 2008 02:12 
You need to put HTML for the table between

if($action==''){
...

$statsOutput=<<<Out
<table class="forumsmb">
<tr>
<td class="caption5">
<span class="txtSm">{$numUsers}<br><a href="https://www.minibb.com/forums/{$indexphp}action=members">Users list</a></span>
</td>
<td class="caption5" style="text-align:right">
<span class="txtSm">{$lastUserDbLnk}</span>
</td>
</tr>
</table>
Out;

}
in the code shown above.

Then put {$statsOutput} in main_footer template.

Author Sergeusz
Partaker
#13 | Posted: 2 May 2008 11:20 
Thank you, it's perfect)

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 Displaying total count of users and latest registered member on the first page
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Get the File and Picture Attachments add-on: extend your miniBB-forums, attaching images and files.


  ⇑