phpBB SnippetsComma separators in numbers

Post Reply
User avatar
Topic Starter
Restless Rancor
Great Britain

Site Admin
New Member
Posts: 48
Joined: October 15th, 2018, 3:14 pm
Age: 25
Location: Hampshire, England
Contact:

Comma separators in numbers

#1

Post by Restless Rancor » October 15th, 2018, 7:11 pm


This snippet adds a comma , separator in numbers across the board.

There are two parts:
  1. Comma separators in numbers. [Go to...]
  2. Statistics manipulation integration. [Go to...]
    • Only follow Part 2 if you have the Statistics Manipulation snippet installed.
    • If you are using Part 2 of that snippet you must adjust your changes accordingly, taking note of the change of ), to )), at the end of each line. (Only applicable if you are using arithmetic operators other than + or -)


Tested On:


Part 1: Comma separators in numbers. [Go to top]

Open root/index.php

Find:

Code: Select all

'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']),
Replace With:

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'])),
'TOTAL_USERS'   => $user->lang('TOTAL_USERS', number_format((int) $config['num_users'])),
Open root/search.php

Find:

Code: Select all

'TOPIC_REPLIES'      => $replies,
'TOPIC_VIEWS'      => $row['topic_views'],
Replace with:

Code: Select all

'TOPIC_REPLIES'      => number_format($replies),
'TOPIC_VIEWS'      => number_format($row['topic_views']),
Open root/viewforum.php

Find:

Code: Select all

'REPLIES'         => $replies,
'VIEWS'            => $row['topic_views'],
Replace with:

Code: Select all

'REPLIES'         => number_format($replies),
'VIEWS'            => number_format($row['topic_views']),
Open root/viewtopic.php

Find:

Code: Select all

'posts'         => $row['user_posts'],
Replace with:

Code: Select all

'posts'         => number_format($row['user_posts']),
Open root/includes/functions_display.php

Find:

Code: Select all

'TOPICS'            => $row['forum_topics'],
Replace with:

Code: Select all

'TOPICS'            => number_format($row['forum_topics']),
Find:

Code: Select all

$post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? $row['forum_posts'] : '';
Replace with:

Code: Select all

$post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? number_format($row['forum_posts']) : '';
Open root/language/en/common.php

Find:

Code: Select all

	'TOTAL_POSTS_COUNT'	=> array(
		2	=> 'Total posts <strong>%d</strong>',
	),
	'TOPIC_REPORTED'	=> 'This topic has been reported',
	'TOTAL_TOPICS'		=> array(
		2	=> 'Total topics <strong>%d</strong>',
	),
	'TOTAL_USERS'		=> array(
		2	=> 'Total members <strong>%d</strong>',
	),
Replace With:

Code: Select all

	'TOTAL_POSTS_COUNT'	=> array(
		2	=> 'Total posts <strong>%s</strong>',
	),
	'TOPIC_REPORTED'	=> 'This topic has been reported',
	'TOTAL_TOPICS'		=> array(
		2	=> 'Total topics <strong>%s</strong>',
	),
	'TOTAL_USERS'		=> array(
		2	=> 'Total members <strong>%s</strong>',
	),

Part 2: Statistics Manipulation integration [Go to top]

Open root/index.php

Find:

Code: Select all

	'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']),
Replace With:

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)),
	'TOTAL_USERS'	=> $user->lang('TOTAL_USERS', number_format((int) $config['num_users'])),
Note: Now follow command 2 onwards in Part 1 (Open: root/search.php!)
Changelog:
► Show Spoiler


These aren't the droids you're looking for.

Post Reply

Topic Subscribers

1 user subscribed to this topic: Restless Rancor