How to show comma's with user points

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   re: How to show comma's with user points
x-caliber
CZ Newbie
x-caliber has been a member for over 20 year's 20 Year Member
usa.gif ohio.gif
Status: Offline
Joined: Aug 21, 2004
0.00 posts per day
Posts: 25
Points: 1,558
   
The above code is the origional code.

Well I dug around and found a few ways to do it with the cash mod, so far I have got the view topic displaying the thousands (comma's).

1. I had to add a function to classes_cash.php
2. I had to go into viewtopic.php and change/add a few things.

When I'm done I'll post it up for ya. Got to figure out a few more things to edit for the rest of it.

I also have the Market MOD which uses the POINTS system. So I am going to figure out that also. Unless someone knows and can tell me how.



Back to top Reply with quote
#2   re: How to show comma's with user points
x-caliber
CZ Newbie
x-caliber has been a member for over 20 year's 20 Year Member
usa.gif ohio.gif
Status: Offline
Joined: Aug 21, 2004
0.00 posts per day
Posts: 25
Points: 1,558
   
Thousands comma's for Cash Mod. (THIS IS THE MOD)

This will add the comma's on the Viewtopic,Profile and donate pages.

Open:
language/lang_english/lang_main.php

Find:
  ?> 

Before that add this:

$lang['dec_point'] = '.';
$lang['thousands_sep'] = ',';


Open:
includes/functions.php
Find:
?> 

Before that add this:

function format_number($int, $decimals = 0) {
   global $lang;
   return number_format($int, $decimals, $lang['dec_point'], $lang['thousands_sep']);
}


Open:
includes/classes_cash.php (Viewtopic,Profile)

Find: The following line and add // in front of each line to disable it.
 
            $template->assign_block_vars('cashrow', array(   'CASH_DISPLAY' => $c_cur->display($postdata[$c_cur->db()])));



After that ADD this:

$cash_display_format = $c_cur->display(format_number($postdata[$c_cur->db()]));
$template->assign_block_vars('cashrow', array(
'CASH_DISPLAY' => $cash_display_format));



Find: The following line and add // infront of each line to disable it.

   $template->assign_block_vars('cashrow', array(   'CASH_NAME' => $c_cur->name(),
                                                'CASH_AMOUNT' => $profiledata[$c_cur->db()]));


After that ADD this:

$cash_amount_format = format_number($profiledata[$c_cur->db()]);
$template->assign_block_vars('cashrow', array(
'CASH_NAME' => $c_cur->name(),
'CASH_AMOUNT' => $cash_amount_format));



OPEN
modules/forums/cash.php (donate page)

Find: The following line and add // in front of each line to disable it.

         $template->assign_block_vars('cashrow',array(   
              'CASH_NAME' => $c_cur->name(),
               'RECEIVER_AMOUNT' => $profiledata[$c_cur->db()],
               'DONATER_AMOUNT' => $userdata[$c_cur->db()],
               'S_DONATE_FIELD' => 'cash[' . $c_cur->id() . ']')
         );



After that ADD this:

      $donater_amount_format = format_number($userdata[$c_cur->db()]);
      $receiver_amount_format = format_number($profiledata[$c_cur->db()]);
      $template->assign_block_vars('cashrow', array(
      'CASH_NAME' => $c_cur->name(),
      'RECEIVER_AMOUNT' => $receiver_amount_format,
      'DONATER_AMOUNT' => $donater_amount_format,
      'S_DONATE_FIELD' => 'cash[' . $c_cur->id() . ']'));



Back to top Reply with quote
#3   re: How to show comma's with user points
scz74
CZ Active Member
scz74 has been a member for over 20 year's 20 Year Member
philippines.gif
Age: 50
Gender: Male
Website:
Status: Offline
Joined: Aug 15, 2004
0.02 posts per day
Posts: 145
Points: 7,972
   
hi x-caliber great work! though i noticed that the cents dont show up anymore. my forums give .02 dollars per posted letters so cents always shows up how do i configure to put the last 2 decimals back?



Back to top Reply with quote
#4   re: How to show comma's with user points
x-caliber
CZ Newbie
x-caliber has been a member for over 20 year's 20 Year Member
usa.gif ohio.gif
Status: Offline
Joined: Aug 21, 2004
0.00 posts per day
Posts: 25
Points: 1,558
   
Thanks,

Ok, go into your includes/functions.php file

find this code:
function format_number($int, $decimals = 0) { 



Change it to this:

function format_number($int, $decimals = 2) { 



The number 2 in there gives you the decimal places.


Back to top Reply with quote
#5   re: How to show comma's with user points
scz74
CZ Active Member
scz74 has been a member for over 20 year's 20 Year Member
philippines.gif
Age: 50
Gender: Male
Website:
Status: Offline
Joined: Aug 15, 2004
0.02 posts per day
Posts: 145
Points: 7,972
   
hey thanks x-caliber. youre good man you can moderate your own fix site. icon_wink.gif



Back to top Reply with quote
#6   re: How to show comma's with user points
x-caliber
CZ Newbie
x-caliber has been a member for over 20 year's 20 Year Member
usa.gif ohio.gif
Status: Offline
Joined: Aug 21, 2004
0.00 posts per day
Posts: 25
Points: 1,558
   
Well I'm learning. Just had to have those comma's.



Back to top Reply with quote
#7   re: How to show comma's with user points
MrFraud
CZ Newbie
MrFraud has been a member for over 19 year's 19 Year Member
philippines.gif
Gender: Male
Status: Offline
Joined: Oct 21, 2005
0.00 posts per day
Posts: 5
Points: 704
   
How about also changing the number format in a userinfo page at the "Your Account" module. I did the codes and instructions posted above here and it was good, the points/cash are now better to look at, but the code seems to leave this "Your Account" module untouched and the same no-comma format shows up. Question is... that how do we change the format of this points shown up and what other files do we need to edit. Also, what if the Shop Mod was also installed what file would be edited then



Back to top Reply with quote
#8   re: How to show comma's with user points
x-caliber
CZ Newbie
x-caliber has been a member for over 20 year's 20 Year Member
usa.gif ohio.gif
Status: Offline
Joined: Aug 21, 2004
0.00 posts per day
Posts: 25
Points: 1,558
   
In the File Modules/Your_Account/index.php
Find This:

function userCheck($username, $user_email) {


Before it Add this:

function format_number($int, $decimals = 0) {
global $lang;
   return number_format($int, $decimals, $lang['dec_point'], $lang['thousands_sep']);
}


The varible name $n_points has seemed to change between Nuke Versions. So depending on your version Its $n_points or $numpoints. However it should make no difference since they are querrying the DB each time its used.

Find this (there are 2 instances of it, same code though)

$numpoints = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$user_prefix."_users WHERE username='$cookie[1]'"));
$n_points = intval($numpoints['points']);
echo ""._YOUHAVEPOINTS." <b>$n_points</b><br>";

Replace with:


$numpoints = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$user_prefix."_users WHERE username='$cookie[1]'"));
$numpointx = format_number($numpoints[points]);
echo ""._YOUHAVEPOINTS." <b>$numpointx</b><br>";



Back to top Reply with quote
#9   re: How to show comma's with user points
x-caliber
CZ Newbie
x-caliber has been a member for over 20 year's 20 Year Member
usa.gif ohio.gif
Status: Offline
Joined: Aug 21, 2004
0.00 posts per day
Posts: 25
Points: 1,558
   
And For The Shop Mod I had to mod it.
I'll post a new thread for that.



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum