How would I put a comma in grandtotal when the count is over a thousand, hundred thousand, etc. As it is now the total looks like 120540. I would like to put in a comma so it would look like 120,540. I am not good at coding, and clueless on how this may be done, if it can be done at all.
Oct 13, 2001, 11:32 AM
Administrator (9387 posts)
Oct 13, 2001, 11:32 AM
Post #2 of 13
Views: 4955
From the perl faq you can use:
local $_ = shift;
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
and if you pass call commify(120540) it will return 120,450.
Cheers,
Alex
--
Gossamer Threads Inc.
Code:
sub commify { local $_ = shift;
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
and if you pass call commify(120540) it will return 120,450.
Cheers,
Alex
--
Gossamer Threads Inc.
Oct 15, 2001, 11:43 AM
Administrator (9387 posts)
Oct 15, 2001, 11:43 AM
Post #4 of 13
Views: 4973
Hi,
You would want to do something like:
grand_total_formatted =>
my $tags = shift;
local $_ = $tags->{grand_total};
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
and add that into your template globals. Then replace <%grand_total%> with <%grand_total_formatted%> in your template.
Cheers,
Alex
--
Gossamer Threads Inc.
You would want to do something like:
grand_total_formatted =>
Code:
sub { my $tags = shift;
local $_ = $tags->{grand_total};
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
and add that into your template globals. Then replace <%grand_total%> with <%grand_total_formatted%> in your template.
Cheers,
Alex
--
Gossamer Threads Inc.
Nov 16, 2001, 3:21 PM
Administrator (9387 posts)
Nov 16, 2001, 3:21 PM
Post #9 of 13
Views: 4835
Quote:
How do you put a comma in the Number_of_Links displayed next to the category name??Try:
Code:
sub { my $tags = shift;
local $_ = $tags->{Number_of_Links};
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
Cheers,
Alex
--
Gossamer Threads Inc.
Feb 6, 2002, 4:03 AM
User (84 posts)
Feb 6, 2002, 4:03 AM
Post #11 of 13
Views: 4766
Hi,
I can understand the change to globals and then change the tag in the template in order to put the comma in the total number of links, however, I am lost at how to do it for category1 (123,456). What template should be changed as I am not sure how to change the tags here to generate the outcome above.
Thanks.
Webmaster
http://www.e-bannerx.com
I can understand the change to globals and then change the tag in the template in order to put the comma in the total number of links, however, I am lost at how to do it for category1 (123,456). What template should be changed as I am not sure how to change the tags here to generate the outcome above.
Thanks.
Webmaster
http://www.e-bannerx.com
Feb 6, 2002, 9:21 AM
Administrator (9387 posts)
Feb 6, 2002, 9:21 AM
Post #12 of 13
Views: 4782
Hi,
Add a global called Number_Formatted:
sub {
my $tags = shift;
local $_ = $tags->{Number_of_Links};
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
then edit subcategory.html and replace <%Number_of_Links%> with <%Number_Formatted%>.
Cheers,
Alex
--
Gossamer Threads Inc.
Add a global called Number_Formatted:
sub {
my $tags = shift;
local $_ = $tags->{Number_of_Links};
return 0 unless defined $_;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
then edit subcategory.html and replace <%Number_of_Links%> with <%Number_Formatted%>.
Cheers,
Alex
--
Gossamer Threads Inc.