tags:

views:

27

answers:

3

if $this->Session->setFlash('this is message','flash_error'); only need create flash_error.ctp in elements folder.

Then $this->Session->setFlash('this is message'). How modify it. I dont want modify only css or javascript

+1  A: 

According to CakePHP book entry on flash():

<?= $session->flash(); ?>

in a view file outputs:

<div id='flashMessage' class='message'>My Message</div>

So there is nothing to override but the CSS for this id in cake.generic.css.

Hope I understood the question correctly. =)

Laheab
No, i want create something like flash_error.ctp in elements folder that overdrive default message of cakephp, my app is very many $this->Session->setFlash('this is message')
meotimdihia
What part do you exactly want to override? The text or the style?
Laheab
A: 

Have you tried to create a default.ctp in elements folder.
That might be what you wanted?

Regards
The-Di-Lab
www.startutorial.com

The-Di-Lab
sorry, but it dont work
meotimdihia
A: 

Laheab answer is right. But you can hack it using Controller beforeRender function. In your app/app_controller.php write this function :

function beforeRender(){
    if ($this->Session->check('Message.flash')) {
        $flash = $this->Session->read('Message.flash');

        if ($flash['element'] == 'default') {
            $flash['element'] = 'flash_error';
            $this->Session->write($flash);
        }
    }
}

It will override the 'default' flash element with 'flash_error'. Then in app/views/elements create flash_error.ctp.

Jamal Aziz