Total Group Members on Index Stats

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
Farraday
Registered User
Posts: 14
Joined: Mon Jan 01, 2024 1:08 am

Total Group Members on Index Stats

Post by Farraday »

Hello again,

I am wanting to show the total number of members in certain groups on my index page (This is a roleplaying forum, so stats for number of players, different character races, etc., which all have their own groups.)

In my search for this, I came across this topic and this topic, but the information appears to be outdated, and my very-amateur attempts to cobble together a solution from that code has not worked.

If anyone with better php expertise could either point me to, or provide a solution to this, I would be very grateful!

Thank you for considering!
User avatar
Anișor
Translator
Posts: 330
Joined: Tue Jan 08, 2013 9:36 pm
Location: Arbroath, Angus, Scotland

Re: Total Group Members on Index Stats

Post by Anișor »

The topics you mentioned are for something else.
Do you want to edit the current legend of the forum or to have a new section with all groups?
Farraday
Registered User
Posts: 14
Joined: Mon Jan 01, 2024 1:08 am

Re: Total Group Members on Index Stats

Post by Farraday »

I'm sorry for the delay, I must have forgotten to click notify me!
Anișor wrote: Sat Sep 14, 2024 8:43 am The topics you mentioned are for something else.
Do you want to edit the current legend of the forum or to have a new section with all groups?
I have custom theme on my board with extensive HTML and CSS changes, and I would like to add the current total counts for two groups to a modified version of the stats section, and then for five other groups to a different section I have at the top of the board.

Edited to add that I don't need the legend edited.
Farraday
Registered User
Posts: 14
Joined: Mon Jan 01, 2024 1:08 am

Re: Total Group Members on Index Stats

Post by Farraday »

I figured this out on my own. The first post I linked above by Phil is in fact the correct method for doing this — The trouble I ran into was that

Code: Select all

$total_users    = $config['num_users']; 
is no longer in index.php, and I had placed the additional php code in the wrong place — If you are new to php, make sure your code is after a semi-colon. I placed all of mine after

Code: Select all

$controller_helper = $phpbb_container->get('controller.helper');
and it worked perfectly.

You can call as many different group totals as you like using the linked method, just change the variable names and group numbers, and make sure you follow all steps every time for each group.
User avatar
Anișor
Translator
Posts: 330
Joined: Tue Jan 08, 2013 9:36 pm
Location: Arbroath, Angus, Scotland

Re: Total Group Members on Index Stats

Post by Anișor »

You should rather write an extension for this that will return the member count for each group instead and then you can show whatever you want.
It's not recommended to edit phpBB's core files.

Return to “phpBB Custom Coding”