This snippet enables you to manipulate the numbers displayed on the index's statistics display.
It also enables you to prevent hidden forums (a staff forum for example) from being counted in the display.
It comes in three parts. Read them carefully:
- Ignore Private Forums in Statistics. [Go to...]
- Statistics Manipulation. [Go to...]
- Comma separation in numbers integration.
Only follow Part 3 if you have this snippet installed already. If you do, you can install Parts 3a and 3b, or both.
Note: Before you ask, because someone will, we only utilize Part 3a of this snippet on this forum.
Also Note: My original request for this code has been released as an extension for phpBB 3.2.3. This snippet still works but is untested with the extension. I'll get to that soon. [Extension Link]
Tested On:
Part 1: Ignore Private Forums In Statistics. [Go to top]
Open
root/index.php
Find:
Code: Select all
// Assign index specific vars
$template->assign_vars(array(
'TOTAL_POSTS' => $user->lang('TOTAL_POSTS_COUNT', (int) $config['num_posts']),
'TOTAL_TOPICS' => $user->lang('TOTAL_TOPICS', (int) $config['num_topics']),
Code: Select all
$sql = 'SELECT forum_id, forum_posts_approved, forum_topics_approved
FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', array(FORUM_ID, FORUM_ID2));
$result = $db->sql_query($sql);
$hidden_posts = 0;
$hidden_topics = 0;
while ($row = $db->sql_fetchrow($result))
{
$hidden_posts += (int) $row['forum_posts_approved'];
$hidden_topics += (int) $row['forum_topics_approved'];
}
$db->sql_freeresult($result);
// Assign index specific vars
$template->assign_vars(array(
'TOTAL_POSTS' => $user->lang('TOTAL_POSTS_COUNT', (int) $config['num_posts'] - $hidden_posts),
'TOTAL_TOPICS' => $user->lang('TOTAL_TOPICS', (int) $config['num_topics'] - $hidden_topics),
FORUM_ID
and FORUM_ID2
to the forum ID's of the forums you want to exclude from the statistics. For example, that line could show:WHERE ' . $db->sql_in_set('forum_id', array(5,6,11));
which will hide forum 5, 6 and 11 from the statistics.
Note: You'll need to Resynchronise statistics and post counts via your ACP when you delete a topic/post.
Part 2: Statistics Manipulation. [Go to top]
Open
root/index.php
To manipulate Total Posts:
Find:
Code: Select all
'TOTAL_POSTS' => $user->lang('TOTAL_POSTS_COUNT', (int) $config['num_posts'] - $hidden_posts),
Code: Select all
$config['num_posts'] - $hidden_posts
Code: Select all
+x
Find:
Code: Select all
'TOTAL_TOPICS' => $user->lang('TOTAL_TOPICS', (int) $config['num_topics'] - $hidden_topics),
Code: Select all
$config['num_topics'] - $hidden_topics
Code: Select all
+x
Find:
Code: Select all
'TOTAL_USERS' => $user->lang('TOTAL_USERS', (int) $config['num_users']),
Code: Select all
$config['num_users']
Code: Select all
+x
x
with the number to increase, replace +
with an alternative arithmetic operator if needed:To use multiplication or division you must remember BIDMAS. An example of total posts multiplied by 100:
($config['num_posts'] - $hidden_posts)*100),
(Total Posts take away hidden posts) multiplied by 100
The number starts at
$
so the opening parenthesis is placed before it. The number ends before ),
so the closing parenthesis goes before it.Don't get confused by the closing
),
- this is not part of the number.Usable Arithmetic Operators:
+
Sum of $x and $y-
Difference of $x and $yMust consider BIDMAS:
*
Product of $x and $y%
Remainder of $x divided by $y**
Result of raising $x to the $y'th powerSource
Example of multiple uses, again remember BIDMAS:
(($config['num_users'])+3)**6),
((2 actual members) plus 3) multiply by the power of 6) = 15625
Note: This only effects statistics displayed on the index page.
If you haven't applied the changes in Part 1 you won't see
- $hidden_posts
or - $hidden_topics
but maths is maths, just remember to use BIDMAS.Part 3a: Comma separation in numbers integration: Ignore Private Forums In Statistics: [Go to top]
Open
root/index.php
Find:
Code: Select all
// Assign index specific vars
$template->assign_vars(array(
Code: Select all
$sql = 'SELECT forum_id, forum_posts_approved, forum_topics_approved
FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', array(FORUM_ID, FORUM_ID2));
$result = $db->sql_query($sql);
$hidden_posts = 0;
$hidden_topics = 0;
while ($row = $db->sql_fetchrow($result))
{
$hidden_posts += (int) $row['forum_posts_approved'];
$hidden_topics += (int) $row['forum_topics_approved'];
}
$db->sql_freeresult($result);
Code: Select all
'TOTAL_POSTS' => $user->lang('TOTAL_POSTS_COUNT', number_format((int) $config['num_posts'])),
'TOTAL_TOPICS' => $user->lang('TOTAL_TOPICS', number_format((int) $config['num_topics'])),
Code: Select all
'TOTAL_POSTS' => $user->lang('TOTAL_POSTS_COUNT', number_format((int) $config['num_posts'] - $hidden_posts)),
'TOTAL_TOPICS' => $user->lang('TOTAL_TOPICS', number_format((int) $config['num_topics'] - $hidden_topics)),
FORUM_ID
and FORUM_ID2
to the forum ID's of the forums you want to exclude from the statistics. For example, that line could show:WHERE ' . $db->sql_in_set('forum_id', array(5,6,11));
which will hide forum 5, 6 and 11 from the statistics.
Note: You'll need to Resynchronise statistics and post counts via your ACP when you delete a topic/post.
Part 3b: Comma separation in numbers integration: Statistics Manipulation: [Go to top]
Open
root/index.php
To manipulate Total Posts:
Find:
Code: Select all
'TOTAL_POSTS' => $user->lang('TOTAL_POSTS_COUNT', number_format((int) $config['num_posts'] - $hidden_posts)),
Code: Select all
$config['num_posts'] - $hidden_posts
Code: Select all
+x
Find:
Code: Select all
'TOTAL_TOPICS' => $user->lang('TOTAL_TOPICS', number_format((int) $config['num_topics'] - $hidden_topics)),
Code: Select all
$config['num_topics'] - $hidden_topics
Code: Select all
+x
Find:
Code: Select all
'TOTAL_USERS' => $user->lang('TOTAL_USERS', number_format((int) $config['num_users'])),
Code: Select all
$config['num_users']
Code: Select all
+x
x
with the number to increase, replace +
with an alternative arithmetic operator if needed:To use multiplication or division you must remember BIDMAS. An example of total posts multiplied by 100:
($config['num_posts'] - $hidden_posts)*100)),
(Total Posts take away hidden posts) multiplied by 100
The number starts at
$
so the opening parenthesis is placed before it. The number ends before )),
so the closing parenthesis goes before it.Don't get confused by the closing
)),
- this is not part of the number.Usable Arithmetic Operators:
+
Sum of $x and $y-
Difference of $x and $yMust consider BIDMAS:
*
Product of $x and $y%
Remainder of $x divided by $y**
Result of raising $x to the $y'th powerSource
Example of multiple uses, again remember BIDMAS:
(($config['num_users'])+3)**6),
((2 actual members) plus 3) multiply by the power of 6) = 15625
Note: This only effects statistics displayed on the index page.
If you haven't applied the changes in Part 3a you won't see
- $hidden_posts
or - $hidden_topics
but maths is maths, just remember to use BIDMAS.