One way to do it (I did not, but seems easy), is to use a po or mo
file.
/app/locale/eng/LC_MESSAGES/errors.po
msgstr "msg1";
msgid "The product has been saved";
then in controller:
$this->Session->setFlash( __d('errors', 'msg1'));
hth
On Jun 2, 7:10 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> We've probably all done something like this 1,000 times:
>
> if($this->Product->save($this->data)){
> $this->Session->setFlash('The Product has been saved.');
> $this->redirect(array('controller'=>'index'));
>
> }
>
> Purely out of curiosity, does anyone try to avoid placing messages
> such as 'The Product has been saved.' or other Error messages outside
> of the controller? A long, long time ago (before I ever used Cake) an
> error message method I used was to keep a config file that stored my
> error messages and an ID that I assigned each message. I would then
> in my code refer to errors via an ID as opposed to printing them out
> directly. Does this seem any more "MVC" than having the content of a
> flash message held inside of the Controller? This has absolutely no
> bearing on anything I'm working on at the moment, but it just sort of
> popped into my head.
>
> Also, is there a simple way to assign a class to the flashMessage div?
> Something like "error", "alert" or "message". I know you can specify
> a layout for setFlash messages, but it seems kind of overkill to have
> a different layout if all that's changing is a css class or two.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---