[RC] Total User in Forum 1.0.0

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Suggested Hosts
User avatar
Simuzer
Registered User
Posts: 35
Joined: Thu Dec 06, 2001 12:06 pm
Location: Türkiye
Contact:

[RC] Total User in Forum 1.0.0

Post by Simuzer »

MOD Title: Total User in Forum

MOD Version: 1.0.0

MOD Author:
For Beta 0.1.0: Simuzer (Zafer Sarışahin) http://www.simuzer.com
For 1.0.0 and next : Alexis (Sevdin Filiz) http://www.canversoft.com

MOD Description: in the main (index.php) page of phpBB, number of total users in forum next forum name.

Image

1. if no user in a forum, it is not shown.
2. if a/some user/s in a forum, it is shown.

support phpBB 3.0.1 - phpBB 3.0.2 RC1

OPEN includes/functions.php

FIND

Code: Select all

?>
ADD BEFORE

Code: Select all

/**
* forum içindeki toplam kullanıcı sayısı
*/
function total_user_in_forum($forum_id)
{
	global $db, $config;

	$reading_sql = (!empty($forum_id)) ? ' AND session_forum_id = ' . $forum_id : '';
	
	if ($db->sql_layer === 'sqlite')
	{
		$sql = 'SELECT COUNT(session_id) as num_user
				FROM (
				SELECT DISTINCT session_id
					FROM ' . SESSIONS_TABLE . '
					WHERE session_time >= ' . (time() - ($config['load_online_time'] * 60)) .
				$reading_sql .
		')';
	}
	else
	{
		$sql = 'SELECT COUNT(DISTINCT session_id) as num_user
				FROM ' . SESSIONS_TABLE . '
				WHERE session_time >= ' . (time() - ($config['load_online_time'] * 60)) .
				$reading_sql;
	}
	$result = $db->sql_query($sql);
	$total_users = (int) $db->sql_fetchfield('num_user');
	
	return $total_users;
}
OPEN includes/functions_display.php

FIND

Code: Select all

			foreach ($subforums[$forum_id] as $subforum_id => $subforum_row)
			{
ADD AFTER

Code: Select all

//-- [+] MOD: total user in forum ---------------------------------------
//-- add
//
				$subforum_total_users = total_user_in_forum($subforum_id);
//
//-- [-] MOD: total user in forum ---------------------------------------
FIND

Code: Select all

		$catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false;
ADD AFTER

Code: Select all

//-- [+] MOD: total user in forum ---------------------------------------
//-- add
//
		$forum_total_users = total_user_in_forum($forum_id);
		$subforum_total_users = (isset($subforum_total_users)) ? $subforum_total_users : 0 ;
		$total_users = $forum_total_users + $subforum_total_users;
//
//-- [-] MOD: total user in forum ---------------------------------------
FIND

Code: Select all

			'LAST_POST_SUBJECT'		=> censor_text($last_post_subject),
ADD AFTER

Code: Select all

//-- [+] MOD: total user in forum ---------------------------------------
//-- add
			'USERS_IN_FORUM'		=> ($total_users == 0) ? '' : sprintf($user->lang['USERS_IN_FORUM'], $total_users),
//
//-- [-] MOD: total user in forum ---------------------------------------
OPEN language/en/common.php

FIND

Code: Select all

?>
ADD BEFORE

Code: Select all

//-- [+] MOD: total user in forum ---------------------------------------
//-- add
$lang = array_merge($lang, array(
	'USERS_IN_FORUM'		=> '%s user',
));
//-- [-] MOD: total user in forum ---------------------------------------
OPEN styles/prosilver/template/forumlist_body.html

FIND

Code: Select all

<!-- BEGIN forumrow -->
ADD BEFORE

Code: Select all

<style type="text/css">
<!--
.smallfont {
	font-family:arial;
	font-size: 10px;
	font-weight:bold;
}
.users_in_forum {
	color:#a52a2a;
}
-->
</style>
FIND

Code: Select all

					<a href="{forumrow.U_VIEWFORUM}" class="forumtitle">{forumrow.FORUM_NAME}</a><br />
CHANGE THIS

Code: Select all

					<a href="{forumrow.U_VIEWFORUM}" class="forumtitle">{forumrow.FORUM_NAME}</a>
					<!-- IF forumrow.USERS_IN_FORUM -->
					<span class="smallfont">(<span class="users_in_forum">{forumrow.USERS_IN_FORUM}</span>)</span>
					<!-- ENDIF -->
					<br />
OPEN styles/subsilver2/template/forumlist_body.html

FIND

Code: Select all

<table class="tablebg" cellspacing="1" width="100%">
ADD BEFORE

Code: Select all

<style type="text/css">
<!--
.smallfont {
	font-family:arial;
	font-size: 10px;
	font-weight:bold;
}
.users_in_forum {
	color:#a52a2a;
}
-->
</style>
FIND

Code: Select all

				<a class="forumlink" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a>
				<p class="forumdesc">{forumrow.FORUM_DESC}</p>
				<!-- IF forumrow.MODERATORS -->
CHANGE THIS

Code: Select all

				<a class="forumlink" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a><!-- IF forumrow.USERS_IN_FORUM --> <span class="smallfont">(<span class="users_in_forum">{forumrow.USERS_IN_FORUM}</span>)</span><!-- ENDIF -->
				<p class="forumdesc">{forumrow.FORUM_DESC}</p>
				<!-- IF forumrow.MODERATORS -->
Last edited by Simuzer on Sun Jul 06, 2008 9:10 pm, edited 6 times in total.
http://www.simuzer.com | Bir sen bir de ben..
TIM3PORT
Registered User
Posts: 221
Joined: Fri May 25, 2007 5:35 pm
Location: New Jersey
Contact:

Re: [BETA] Total User in Forum 0.1.0

Post by TIM3PORT »

I really like this very easy install and I know how you hve comments to all your edits so in case someone wants to remove the mod it will be a lot easier to find.
MattiEsport
Registered User
Posts: 57
Joined: Sun Feb 11, 2007 11:34 am

Re: [BETA] Total User in Forum 0.1.0

Post by MattiEsport »

This mod isn't working on my forum ;(
My forum www.stylesbb.dl.pl here you can get FREE PHPBB3 and PHPBB styles !
TIM3PORT
Registered User
Posts: 221
Joined: Fri May 25, 2007 5:35 pm
Location: New Jersey
Contact:

Re: [BETA] Total User in Forum 0.1.0

Post by TIM3PORT »

did you refresh your board cache just in case?

it doesn't really take much to get this working please post the edits you did
User avatar
chadtm80
Registered User
Posts: 166
Joined: Mon Jan 06, 2003 8:05 pm
Contact:

Re: [BETA] Total User in Forum 0.1.0

Post by chadtm80 »

This not work with subsilver2?
http://www.bigmoeknow.com/forum/index.php

YOUR HOME FOR SPORTS INFOMATION & THE BEST COLLECTION OF 'CAPPERS ON THE NET
TIM3PORT
Registered User
Posts: 221
Joined: Fri May 25, 2007 5:35 pm
Location: New Jersey
Contact:

Re: [BETA] Total User in Forum 0.1.0

Post by TIM3PORT »

that should do it please verify as I did not test since I do not use subsilver on my forums

/styles/subsilver2/template/forumlist_body.html

#--- [ FIND ] ----------------------------

Code: Select all

				<a class="forumlink" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a>
				<p class="forumdesc">{forumrow.FORUM_DESC}</p>
#--- [ REPLACE THIS ] ----------------------------

Code: Select all

				<a class="forumlink" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a> {forumrow.USERS_IN_FORUM}
				<p class="forumdesc">{forumrow.FORUM_DESC}</p>
MattiEsport
Registered User
Posts: 57
Joined: Sun Feb 11, 2007 11:34 am

Re: [BETA] Total User in Forum 0.1.0

Post by MattiEsport »

I'm using proorange ( http://www.emuza.biz/forum/ ) please take a look on it.
My forum www.stylesbb.dl.pl here you can get FREE PHPBB3 and PHPBB styles !
User avatar
chadtm80
Registered User
Posts: 166
Joined: Mon Jan 06, 2003 8:05 pm
Contact:

Re: [BETA] Total User in Forum 0.1.0

Post by chadtm80 »

TIM3PORT wrote:that should do it please verify as I did not test since I do not use subsilver on my forums

/styles/subsilver2/template/forumlist_body.html

#--- [ FIND ] ----------------------------

Code: Select all

				<a class="forumlink" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a>
				<p class="forumdesc">{forumrow.FORUM_DESC}</p>
#--- [ REPLACE THIS ] ----------------------------

Code: Select all

				<a class="forumlink" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a> {forumrow.USERS_IN_FORUM}
				<p class="forumdesc">{forumrow.FORUM_DESC}</p>

Installed it in my subsilver2 and no go.. Dosent show it.. ???
http://www.bigmoeknow.com/forum/index.php

YOUR HOME FOR SPORTS INFOMATION & THE BEST COLLECTION OF 'CAPPERS ON THE NET
TIM3PORT
Registered User
Posts: 221
Joined: Fri May 25, 2007 5:35 pm
Location: New Jersey
Contact:

Re: [BETA] Total User in Forum 0.1.0

Post by TIM3PORT »

I had no uses on my forums at the time I tested this.. so I can't really say my subsilver theme has no mods on it so I won't bother leaving it on.

just use prosilver already LoL

I don't see why it wouldn't work .. maybe give it a little more time to amke sure you have enough people in the forum so you can see it in action.

hav eyou tried cleaning your board cache just in case?
thebluebus
Registered User
Posts: 155
Joined: Sat Dec 31, 2005 6:50 pm
Location: England, UK

Re: [BETA] Total User in Forum 0.1.0

Post by thebluebus »

worked perfectly first time. Very quick mod to do. Really adds to the index page.
thanks alot :D

by the way, how easy is it to add this to viewforum.php too? to show how many are reading each topic?
User avatar
JunglistPerfection
Registered User
Posts: 611
Joined: Mon Apr 09, 2007 11:58 pm
Location: Chicago, IL

Re: [BETA] Total User in Forum 0.1.0

Post by JunglistPerfection »

Yea, all you have to do is prune your cache. And everything should be good to go.
User avatar
Thijs_W
Registered User
Posts: 46
Joined: Thu Feb 08, 2007 12:12 pm
Location: the Netherlands
Contact:

Re: [BETA] Total User in Forum 0.1.0

Post by Thijs_W »

Did anyone tested it on RC7?
User avatar
Simuzer
Registered User
Posts: 35
Joined: Thu Dec 06, 2001 12:06 pm
Location: Türkiye
Contact:

Re: [BETA] Total User in Forum 0.1.0

Post by Simuzer »

Yes, it works on RC7
http://www.simuzer.com | Bir sen bir de ben..
RedTrinity
Registered User
Posts: 1327
Joined: Sat May 06, 2006 3:32 am

Re: [BETA] Total User in Forum 0.1.0

Post by RedTrinity »

Installed perfectly without a hitch, thanks heaps :D

Just a suggestion - to avoid the 'user/s' plural issue, why not change it to "viewing" instead?

That way any number plurals will work with it no matter if its one or more :)
User avatar
Simuzer
Registered User
Posts: 35
Joined: Thu Dec 06, 2001 12:06 pm
Location: Türkiye
Contact:

Re: [BETA] Total User in Forum 0.1.0

Post by Simuzer »

Yeah, you are right :idea:

"viewing" is good idea.

My English not very well :mrgreen:
http://www.simuzer.com | Bir sen bir de ben..
Locked

Return to “[3.0.x] MODs in Development”