Ignore specified forums from statistics

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
User avatar
Restless Rancor
Registered User
Posts: 184
Joined: Tue Sep 18, 2018 1:51 pm

Ignore specified forums from statistics

Post by Restless Rancor » Wed Sep 19, 2018 1:44 pm

Hi, Mick told me to post this over here so here goes:

I used to use the following code in 3.0.x to ignore specified forum's post counts in the board statistics (so private forums would not distort the figures for regular members):

root/index.php find:

Code: Select all

$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';
add after:

Code: Select all

$sql = 'SELECT forum_id, forum_posts, forum_topics
        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 += $row['forum_posts'];
    $hidden_topics += $row['forum_topics'];
}
$db->sql_freeresult($result);
$total_posts  = $config['num_posts'] - $hidden_posts;
$total_topics  = $config['num_topics'] - $hidden_topics;
This doesn't work in 3.2.3 but hopefully it's easily adaptable. Would someone be able to provide an updated method please? It doesn't necessarily have to be an entirely new extension, just the file edits are fine.
Thanks!
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

User avatar
Ger
Recognised Extension Developer
Posts: 1792
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Ignore specified forums from statistics

Post by Ger » Wed Sep 19, 2018 2:17 pm

In what way doesn't it work?
Is there just nothing happening, do you get errors, a blank page, is the world exploding? ;)

Also, isn't the forum permission "Increment post counter" enough for your purpose?
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51445
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Ignore specified forums from statistics

Post by Brf » Wed Sep 19, 2018 2:22 pm

Ger wrote:
Wed Sep 19, 2018 2:17 pm
Also, isn't the forum permission "Increment post counter" enough for your purpose?
I do not think that permission affects the Totals. I seem to remember someone complaining about that a couple months ago.

User avatar
Restless Rancor
Registered User
Posts: 184
Joined: Tue Sep 18, 2018 1:51 pm

Re: Ignore specified forums from statistics

Post by Restless Rancor » Wed Sep 19, 2018 3:52 pm

Ger wrote:
Wed Sep 19, 2018 2:17 pm
In what way doesn't it work?
Is there just nothing happening, do you get errors, a blank page, is the world exploding? ;)

Also, isn't the forum permission "Increment post counter" enough for your purpose?
Hi,
"Increment post counter" prevents the users post count increasing, but the board statistics on the index page still increase.

I've opened root/index.php and this code no longer exists:

Code: Select all

$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';
The closest I've found is:

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']),
	'TOTAL_USERS'	=> $user->lang('TOTAL_USERS', (int) $config['num_users']),
	'NEWEST_USER'	=> $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),

	'LEGEND'		=> $legend,
	'BIRTHDAY_LIST'	=> (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list),

	'FORUM_IMG'				=> $user->img('forum_read', 'NO_UNREAD_POSTS'),
	'FORUM_UNREAD_IMG'			=> $user->img('forum_unread', 'UNREAD_POSTS'),
	'FORUM_LOCKED_IMG'		=> $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
	'FORUM_UNREAD_LOCKED_IMG'	=> $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),

	'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'U_SEND_PASSWORD'           => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '',
	'S_DISPLAY_BIRTHDAY_LIST'	=> (!empty($birthday_list)) ? $show_birthdays : false,
	'S_INDEX'					=> true,

	'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '',
	'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);
I have placed the code in various different ways around/within the above code and have had varying results. Some where nothing happens, some where an error is thrown, but no instances where it's worked how I'd like it to.

Thanks
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

User avatar
GanstaZ
Jr. Extension Validator
Posts: 658
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: Ignore specified forums from statistics

Post by GanstaZ » Wed Sep 19, 2018 4:43 pm

Can't you see the difference in code? There's no $total_posts or $total_topics injected into $template->assign_vars() method. Here's something to try:

Code: Select all

while ($row = $db->sql_fetchrow($result))
{
    $hidden_posts  += (int) $row['forum_posts'];
    $hidden_topics += (int) $row['forum_topics'];
}
$db->sql_freeresult($result);

$total_posts  = (int) $config['num_posts'] - $hidden_posts;
$total_topics = (int) $config['num_topics'] - $hidden_topics;

// Assign index specific vars
$template->assign_vars(array(
	'TOTAL_POSTS'	=> $user->lang('TOTAL_POSTS_COUNT', $total_posts),
	'TOTAL_TOPICS'	=> $user->lang('TOTAL_TOPICS', $total_topics),

        ***
);
"When answer lies in the question,.. question becomes redundant!"

User avatar
Restless Rancor
Registered User
Posts: 184
Joined: Tue Sep 18, 2018 1:51 pm

Re: Ignore specified forums from statistics

Post by Restless Rancor » Wed Sep 19, 2018 5:00 pm

GanstaZ wrote:
Wed Sep 19, 2018 4:43 pm
Can't you see the difference in code? There's no $total_posts or $total_topics injected into $template->assign_vars() method. Here's something to try:

Code: Select all

while ($row = $db->sql_fetchrow($result))
{
    $hidden_posts  += (int) $row['forum_posts'];
    $hidden_topics += (int) $row['forum_topics'];
}
$db->sql_freeresult($result);

$total_posts  = (int) $config['num_posts'] - $hidden_posts;
$total_topics = (int) $config['num_topics'] - $hidden_topics;

// Assign index specific vars
$template->assign_vars(array(
	'TOTAL_POSTS'	=> $user->lang('TOTAL_POSTS_COUNT', $total_posts),
	'TOTAL_TOPICS'	=> $user->lang('TOTAL_TOPICS', $total_topics),

        ***
);
Hi, I can see the difference but as far as understanding precisely what things mean that's where I fail.

I've applied the code you suggested, so it now shows as:

Code: Select all

while ($row = $db->sql_fetchrow($result))
{
    $hidden_posts  += (int) $row['forum_posts'];
    $hidden_topics += (int) $row['forum_topics'];
}
$db->sql_freeresult($result);

$total_posts  = (int) $config['num_posts'] - $hidden_posts;
$total_topics = (int) $config['num_topics'] - $hidden_topics;

// Assign index specific vars
$template->assign_vars(array(
	'TOTAL_POSTS'	=> $user->lang('TOTAL_POSTS_COUNT', $total_posts),
	'TOTAL_TOPICS'	=> $user->lang('TOTAL_TOPICS', $total_topics),
	'TOTAL_USERS'	=> $user->lang('TOTAL_USERS', (int) $config['num_users']),
	'NEWEST_USER'	=> $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),

	'LEGEND'		=> $legend,
	'BIRTHDAY_LIST'	=> (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list),

	'FORUM_IMG'				=> $user->img('forum_read', 'NO_UNREAD_POSTS'),
	'FORUM_UNREAD_IMG'			=> $user->img('forum_unread', 'UNREAD_POSTS'),
	'FORUM_LOCKED_IMG'		=> $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
	'FORUM_UNREAD_LOCKED_IMG'	=> $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),

	'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'U_SEND_PASSWORD'           => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '',
	'S_DISPLAY_BIRTHDAY_LIST'	=> (!empty($birthday_list)) ? $show_birthdays : false,
	'S_INDEX'					=> true,

	'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '',
	'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);

The original code being:

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']),
	'TOTAL_USERS'	=> $user->lang('TOTAL_USERS', (int) $config['num_users']),
	'NEWEST_USER'	=> $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),

	'LEGEND'		=> $legend,
	'BIRTHDAY_LIST'	=> (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list),

	'FORUM_IMG'				=> $user->img('forum_read', 'NO_UNREAD_POSTS'),
	'FORUM_UNREAD_IMG'			=> $user->img('forum_unread', 'UNREAD_POSTS'),
	'FORUM_LOCKED_IMG'		=> $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
	'FORUM_UNREAD_LOCKED_IMG'	=> $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),

	'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'U_SEND_PASSWORD'           => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '',
	'S_DISPLAY_BIRTHDAY_LIST'	=> (!empty($birthday_list)) ? $show_birthdays : false,
	'S_INDEX'					=> true,

	'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '',
	'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);
Unfortunately that didn't work, and errors are shown in the header:

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 255: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 317: mysqli_free_result(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4541: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3291)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4541: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3291)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4541: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3291)
In my original code I had to specify which forums to ignore, have I missed where to put this in the code you supplied or is it working differently?

Thanks
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

User avatar
GanstaZ
Jr. Extension Validator
Posts: 658
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: Ignore specified forums from statistics

Post by GanstaZ » Wed Sep 19, 2018 5:23 pm

Did you insert this as well before while loop?

Code: Select all

$sql = 'SELECT forum_id, forum_posts, forum_topics
        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;
It should look like this:

Code: Select all

$sql = 'SELECT forum_id, forum_posts, forum_topics
        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'];
    $hidden_topics += (int) $row['forum_topics'];
}
$db->sql_freeresult($result);

$total_posts  = (int) $config['num_posts'] - $hidden_posts;
$total_topics = (int) $config['num_topics'] - $hidden_topics;

// Assign index specific vars
$template->assign_vars(array(
	'TOTAL_POSTS'	=> $user->lang('TOTAL_POSTS_COUNT', $total_posts),
	'TOTAL_TOPICS'	=> $user->lang('TOTAL_TOPICS', $total_topics),
	'TOTAL_USERS'	=> $user->lang('TOTAL_USERS', (int) $config['num_users']),
	'NEWEST_USER'	=> $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),

	'LEGEND'		=> $legend,
	'BIRTHDAY_LIST'	=> (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list),

	'FORUM_IMG'				=> $user->img('forum_read', 'NO_UNREAD_POSTS'),
	'FORUM_UNREAD_IMG'			=> $user->img('forum_unread', 'UNREAD_POSTS'),
	'FORUM_LOCKED_IMG'		=> $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
	'FORUM_UNREAD_LOCKED_IMG'	=> $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),

	'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'U_SEND_PASSWORD'           => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '',
	'S_DISPLAY_BIRTHDAY_LIST'	=> (!empty($birthday_list)) ? $show_birthdays : false,
	'S_INDEX'					=> true,

	'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '',
	'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);
"When answer lies in the question,.. question becomes redundant!"

User avatar
Restless Rancor
Registered User
Posts: 184
Joined: Tue Sep 18, 2018 1:51 pm

Re: Ignore specified forums from statistics

Post by Restless Rancor » Wed Sep 19, 2018 5:47 pm

GanstaZ wrote:
Wed Sep 19, 2018 5:23 pm
Did you insert this as well before while loop?

Code: Select all

$sql = 'SELECT forum_id, forum_posts, forum_topics
        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;
It should look like this:

Code: Select all

$sql = 'SELECT forum_id, forum_posts, forum_topics
        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'];
    $hidden_topics += (int) $row['forum_topics'];
}
$db->sql_freeresult($result);

$total_posts  = (int) $config['num_posts'] - $hidden_posts;
$total_topics = (int) $config['num_topics'] - $hidden_topics;

// Assign index specific vars
$template->assign_vars(array(
	'TOTAL_POSTS'	=> $user->lang('TOTAL_POSTS_COUNT', $total_posts),
	'TOTAL_TOPICS'	=> $user->lang('TOTAL_TOPICS', $total_topics),
	'TOTAL_USERS'	=> $user->lang('TOTAL_USERS', (int) $config['num_users']),
	'NEWEST_USER'	=> $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),

	'LEGEND'		=> $legend,
	'BIRTHDAY_LIST'	=> (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list),

	'FORUM_IMG'				=> $user->img('forum_read', 'NO_UNREAD_POSTS'),
	'FORUM_UNREAD_IMG'			=> $user->img('forum_unread', 'UNREAD_POSTS'),
	'FORUM_LOCKED_IMG'		=> $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
	'FORUM_UNREAD_LOCKED_IMG'	=> $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),

	'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'U_SEND_PASSWORD'           => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '',
	'S_DISPLAY_BIRTHDAY_LIST'	=> (!empty($birthday_list)) ? $show_birthdays : false,
	'S_INDEX'					=> true,

	'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '',
	'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);
Hi, no I didn't. I've applied that and changed array(FORUM_ID, FORUM_ID2)); to array(4, 5)); (the ID's of the forums I want to exclude) but now loading the index shows a General Error:

Code: Select all

General Error
SQL ERROR [ mysqli ]

Unknown column 'forum_posts' in 'field list' [1054]

SQL

SELECT forum_id, forum_posts, forum_topics FROM phpbb_forums WHERE forum_id IN (4, 5)

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 997
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 193
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 329
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/index.php
LINE: 206
CALL: phpbb\db\driver\factory->sql_query()
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

User avatar
GanstaZ
Jr. Extension Validator
Posts: 658
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: Ignore specified forums from statistics

Post by GanstaZ » Wed Sep 19, 2018 6:22 pm

Yeah.. i forgot that there are no such fields in forums table. I'll check it later, when i have time or maybe someone else will pop in and fix the sql.
"When answer lies in the question,.. question becomes redundant!"

User avatar
Restless Rancor
Registered User
Posts: 184
Joined: Tue Sep 18, 2018 1:51 pm

Re: Ignore specified forums from statistics

Post by Restless Rancor » Wed Sep 19, 2018 6:24 pm

GanstaZ wrote:
Wed Sep 19, 2018 6:22 pm
Yeah.. i forgot that there are no such fields in forums table. I'll check it later, when i have time or maybe someone else will pop in and fix the sql.
No problem, I appreciate your help so far!
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

User avatar
GanstaZ
Jr. Extension Validator
Posts: 658
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: Ignore specified forums from statistics

Post by GanstaZ » Thu Sep 20, 2018 5:56 am

Made on the fly, but should do the trick:

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),
	'TOTAL_USERS'	=> $user->lang('TOTAL_USERS', (int) $config['num_users']),
	'NEWEST_USER'	=> $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),

	'LEGEND'		=> $legend,
	'BIRTHDAY_LIST'	=> (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list),

	'FORUM_IMG'				=> $user->img('forum_read', 'NO_UNREAD_POSTS'),
	'FORUM_UNREAD_IMG'			=> $user->img('forum_unread', 'UNREAD_POSTS'),
	'FORUM_LOCKED_IMG'		=> $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
	'FORUM_UNREAD_LOCKED_IMG'	=> $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),

	'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'U_SEND_PASSWORD'           => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '',
	'S_DISPLAY_BIRTHDAY_LIST'	=> (!empty($birthday_list)) ? $show_birthdays : false,
	'S_INDEX'					=> true,

	'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '',
	'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);
Of course there are many ways how to do this: with permissions (automatic forum ids) or acp setting where you can set ids (manual way) and so on.
"When answer lies in the question,.. question becomes redundant!"

User avatar
Restless Rancor
Registered User
Posts: 184
Joined: Tue Sep 18, 2018 1:51 pm

Re: Ignore specified forums from statistics

Post by Restless Rancor » Thu Sep 20, 2018 9:32 am

GanstaZ wrote:
Thu Sep 20, 2018 5:56 am
Made on the fly, but should do the trick:

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),
	'TOTAL_USERS'	=> $user->lang('TOTAL_USERS', (int) $config['num_users']),
	'NEWEST_USER'	=> $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),

	'LEGEND'		=> $legend,
	'BIRTHDAY_LIST'	=> (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list),

	'FORUM_IMG'				=> $user->img('forum_read', 'NO_UNREAD_POSTS'),
	'FORUM_UNREAD_IMG'			=> $user->img('forum_unread', 'UNREAD_POSTS'),
	'FORUM_LOCKED_IMG'		=> $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
	'FORUM_UNREAD_LOCKED_IMG'	=> $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),

	'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'U_SEND_PASSWORD'           => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '',
	'S_DISPLAY_BIRTHDAY_LIST'	=> (!empty($birthday_list)) ? $show_birthdays : false,
	'S_INDEX'					=> true,

	'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '',
	'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);
Of course there are many ways how to do this: with permissions (automatic forum ids) or acp setting where you can set ids (manual way) and so on.
Hi GanstaZ that worked! Thank you! :mrgreen:
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

User avatar
GanstaZ
Jr. Extension Validator
Posts: 658
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: Ignore specified forums from statistics

Post by GanstaZ » Thu Sep 20, 2018 10:11 am

You're welcome!) Maybe i'll make small extension for this, but it's still just a thought)
"When answer lies in the question,.. question becomes redundant!"

User avatar
Restless Rancor
Registered User
Posts: 184
Joined: Tue Sep 18, 2018 1:51 pm

Re: Ignore specified forums from statistics

Post by Restless Rancor » Thu Sep 20, 2018 10:14 am

GanstaZ wrote:
Thu Sep 20, 2018 10:11 am
You're welcome!) Maybe i'll make small extension for this, but it's still just a thought)
I'll keep my eye out on the Extensions in Development forum, thanks again :ugeek:
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

nou nou
Registered User
Posts: 218
Joined: Sat Oct 29, 2016 8:08 pm

Re: Ignore specified forums from statistics

Post by nou nou » Sat Sep 22, 2018 3:59 pm

GanstaZ wrote:
Thu Sep 20, 2018 10:11 am
You're welcome!) Maybe i'll make small extension for this, but it's still just a thought)
Hi GangstaZ,

Thanks so much for the code snippet!

I too would love to see this as an extension. I have a few private boards plus users keeping track of the total post count to see if there is anything new... :)

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 5 guests