![]() |
Simple Message Handling Library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Simple Message Handling Library (/showthread.php?tid=5153) |
Simple Message Handling Library - El Forum - 01-08-2008 [eluser]Unknown[/eluser] Hey guys, i thought i would post a simple message handling library i came up with. Nothing special but maybe a good foundation for something more involved. currently it has multiple states of a message (success, warn & error). Will be making more improvements soon! should be located in: application/libraries/Message_handler.php probably a good idea to autoload in autoload.php code below: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); in your controller simply use line to add a message: Code: $this->message_handler->add('Your account has been created.'); to display a message use this code, in your view or passed from a controller: Code: $this->CI->message_handler->display() cheers all (codeigniter FTW) Simple Message Handling Library - El Forum - 01-08-2008 [eluser]wemago[/eluser] hmm that looks just like flashmsgs that you can use in sessions ![]() just check the svn for the new CI updates. Simple Message Handling Library - El Forum - 01-08-2008 [eluser]Unknown[/eluser] ill have to check that out cheers! Simple Message Handling Library - El Forum - 01-08-2008 [eluser]Craig A Rodway[/eluser] That's a nice idea, thanks! ![]() This might be useful for styling your boxes: Create a valid CSS alert message (read the comments for some discussion on correct CSS usage though). Mu current method for these sort of messages is like this: 4 view files (error, info, warning, question) in a directory called msgbox. This is my /views/msgbox/error.php file: Code: <p class="msgbox error"><?php echo $vars; ?></p> Although this is not the traditional use for the variable passing to views, it allows me to do this in my controllers and/or views: Code: // Controller: Simple Message Handling Library - El Forum - 12-09-2009 [eluser]koryrok[/eluser] to display a message use this code, in your view or passed from a controller: Code: $this->CI->message_handler->display() Just want to make a quick correction to the code above. It should be: Code: $this->message_handler->display() |