Tuesday, January 12, 2010

[SOLVED] Re: How to format numbers in an e-mail template

Just had a "Duh" moment...

To format the number in the .ctp file, for an e-mail or anything else,
you do the following:

1. Add the helper of 'Number' either to the action or the controller
itself,
2. Use this syntax as an example: <?php echo $number->format
($new_odometer);?>

I was not putting $number in front in order to access the helper.
Hence the "Duh" moment. The CakePHP cookbook shows all the other
options for formatting numbers.

Maybe this will help some other newbie...

On Jan 11, 10:16 pm, Everton Yoshitani <ever...@notreve.com> wrote:
> I'm not sure about the number helper in the element, anyway if you arent
> allowed to use it you could simple use the php functionhttp://jp2.php.net/number_format?
>
> Att,
> Everton
>
> On Tue, Jan 12, 2010 at 2:09 PM, FrederickD <manzanillo.engl...@gmail.com>wrote:
>
> > I have added the helper 'Number' in to controller actions using the
> > statement $this->helpers[] = 'Number';". My goal is to format two
> > whole numbers with commas in the thousands position when sending an e-
> > mail for a more professional presentation.
>
> > The .ctp file paragraph (../app/views/elements/email/html/
> > email_reminder.ctp) containing the replacement variables I want to
> > format looks like this:
>
> > <p>If so, please return to your Service Department for another
> > <b><?php echo $services?></b>
> > before your odometer shows
> > <b><?php echo $new_odometer?> <?php echo $odometer_type?></b>,
> > and we will extend your coverage for another
> > <b><?php echo $service_interval?></b>
> > <b><?php echo $odometer_type?></b>.
>
> > The replacement field variables $new_odometer and $service_interval
> > are numbers in the database. It seemed according to the CakePHP
> > cookbook (http://book.cakephp.org/view/409/format) that I could use a
> > statement like <?php echo $new_odometer->format($new_odometer);?>.
> > However, that doesn't work at all.
>
> > Is there a way to format the number in the controller action, perhaps
> > creating a formatted string field, that then could be sent as the
> > replacement element?
>
> > Thanks in advance!
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com<cake-php%2Bunsubscribe@googlegroups.com>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en
>
>

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate