Simple Message Handling Library |
[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)
[eluser]wemago[/eluser]
hmm that looks just like flashmsgs that you can use in sessions just check the svn for the new CI updates.
[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:
[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() |
Welcome Guest, Not a member yet? Register Sign In |