Or has already been invented by people 5 years ago :D
see my tools plugin for example (Common component + helper)


Am Mittwoch, 4. September 2013 10:51:53 UTC-7 schrieb Jeremy Burns:
>
> How is that more awesome than what you do out of the box?
>
> On 4 Sep 2013, at 16:14, Prashant Shah <[email protected] <javascript:>> 
> wrote:
>
> Hi,
>
> This is first time I am working with cakephp and I was not satisfied with 
> the flash message system in cakephp.
>
> Here is how to setup your own awesome flash system (MIT License) :
>
> - Multiple messages for each type
> - Separate divs for each type
> - Each message shown as <li>
>
> Create a file : app/View/Helper/FlashExtHelper.php
>
> <?php
> // MIT License
> App::uses('AppHelper', 'View/Helper');
> App::uses('CakeSession', 'Model/Datasource');
>
> class FlashExtHelper extends AppHelper {
>
>     public function flashExt() {
>         $out = false;
>
>         if (CakeSession::check('FlashExt')) {
>             $messages = (array)CakeSession::read('FlashExt');
>             foreach($messages as $key => $type) {
>                 $out .= '<div id="flash" class="' . $key . '\">';
>                 $out .= '<ul>';
>                 foreach ($type as $key => $message) {
>                     $out .= '<li>' . $message . '</li>';
>                 }
>                 $out .= '</ul>';
>                 $out .= '</div>';
>             }
>             CakeSession::delete('FlashExt');
>         }
>
>         return $out;
>     }
> }
> ?>
>
> Add the following in app/Controller/AppController.php :
>
> class AppController extends Controller {
>     public $helpers = array('FlashExt');
>
>     // MIT License
>     function setFlashExt($message, $type) {
>         $messages = (array)$this->Session->read('FlashExt');
>         $messages[$type][] = $message;
>         $this->Session->write('FlashExt', $messages);
>     }
> }
>
> Use it in your views :
>
> <?php echo $this->FlashExt->flashExt(); ?>
>
> Use it in your controllers :
>
> $this->setFlashExt('message', 'notice');
> $this->setFlashExt('message', 'success');
> $this->setFlashExt('message', 'error');
>
>
> -- 
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>  
> --- 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected]<javascript:>
> .
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to