1 (edited by ultime 2005-05-01 20:17)

Topic: Number Formating

This Mod was built in PunBB 1.2.5 but should work in most versions, it can be easily modified.
I noticed PunBB wasn't putting commas in the right spot, so I decided to do a little Modification.

For example, if the forums has "5098" posts in total, PunBB will display "5098". With these modifications it will display "5,098".
Please take note that not all servers support the number_format(); command, backup before making any modifications.
Interesting so far?

Alright so open up index.php and search for:

<div id="brdstats" class="block">
<h2><span><?php echo $lang_index['Board info'] ?></span></h2>

Right over, add:

$total_users = number_format($stats['total_users']);
$total_topics = number_format($stats['total_topics']);
$total_posts = number_format($stats['total_posts']);

Now, find:

<dd><?php echo $lang_index['No of users'].': <strong>'. $stats['total_users'] ?></strong></dd>
<dd><?php echo $lang_index['No of topics'].': <strong>'.$stats['total_topics'] ?></strong></dd>
<dd><?php echo $lang_index['No of posts'].': <strong>'.$stats['total_posts'] ?></strong></dd>

And replace with:

<dd><?php echo $lang_index['No of users'].': <strong>'. $total_users ?></strong></dd>
<dd><?php echo $lang_index['No of topics'].': <strong>'.$total_topics ?></strong></dd>
<dd><?php echo $lang_index['No of posts'].': <strong>'.$total_posts ?></strong></dd>

Here we go that's it! You can do the same thing in viewtopic for posts of users.

Footers look much more interesting now heh?

Now, if any french coders are around here, the right french display would be "5 098" and not "5098" or "5,098".
In order to do that you would need to use the following:

$total_users = number_format($stats['total_users'], 0, ',', ' ');
$total_topics = number_format($stats['total_topics'], 0, ',', ' ');
$total_posts = number_format($stats['total_posts'], 0, ',', ' ');

- ultime

Re: Number Formating

nice touch, i'll give a try later tongue