Was just showing another supported way to do it ;)
Sam D
On Jan 24, 2008 7:21 AM, grigri <[EMAIL PROTECTED]> wrote:
>
> sam d:
>
> Yeah, flash layouts are handy. But the added overhead of running a
> layout and whatnot hardly seems worth it for a one-liner message. If
> you were using this in conjunction with the params() to display a
> detailed error/warning/whatever message, I'd agree. But for simple
> static text, I prefer using the 'key' parameter and using the normal
> functionality.
>
> This is just a personal opinion though; to each his own!
>
>
> On Jan 24, 2:13 pm, grigri <[EMAIL PROTECTED]> wrote:
> > //--------------
> >
> > In your controller action:
> >
> > $this->Session->setFlash('There was an error', null, array(),
> > 'error');
> > return;
> >
> > In your layout:
> >
> > // If there's an error, display it - if not, display flash message [if
> > there is one]
> > if (!$session->flash('error')) {
> > $session->flash();
> >
> > }
> >
> > In your css
> >
> > #flashMessage.message {
> > color: blue;
> >
> > }
> >
> > #errorMessage.message {
> > color: red;
> >
> > }
> >
> > //--------------
> >
> > If you really want to make things simple you could do this:
> >
> > class AppController extends Controller {
> > function set($one, $two = null) {
> > parent::set($one, $two);
> > if (isset($this->viewVars['errorMessage'])) {
> > $this->Session->setFlash($this->viewVars['error'], null,
> > array(), 'error');
> > unset($this->viewVars['errorMessage']);
> > }
> > }
> >
> > }
> >
> > then in any controller just do
> >
> > $this->set('errorMessage', 'Something went horribly wrong'); return;
> >
> > (you'll still have to adjust the layout and css as above)
> >
> > On Jan 24, 12:10 pm, Sebastian <[EMAIL PROTECTED]> wrote:
> >
> > > Hey,
> >
> > > it seems like before 1.2 you were able to send errorMessage from the
> > > controller to the view by simply setting:
> >
> > > $this->set('errorMessage', 'There was an error');
> >
> > > This message was then automatically rendered with the appropriate css
> > > class from cakePHP's default css file at the top of the page like a
> > > flash message.
> >
> > > However, in 1.2 this doesn't work anymore :-( The only way I get to
> > > output error messages is by:
> >
> > > $this->Session->setFlash('There was an error!');
> > > $this->render();
> > > $this->exit();
> >
> > > My problem now is, that all these flash messages are rendered with the
> > > same css class (same background, same font color), which makes it hard
> > > to differentiate between an information and an error flash message.
> >
> > > Is there any way to bring back the traditional way to output error
> > > messages? If not, is there a way to define css classes for a flash
> > > message?
> >
> > > Regards,
> >
> > > Sebastian
> >
>
--
--
(the old fart) the advice is free, the lack of crankiness will cost you
- its a fine line between a real question and an idiot
http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/
http://blog.samdevore.com/cakephp-pages/my-cake-wont-bake/
http://blog.samdevore.com/cakephp-pages/i-cant-bake/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---