Giter VIP home page Giter VIP logo

codeigniter-message's Introduction

CodeIgniter-Message

CodeIgniter-Message is a small codeigniter library for giving feedback to the user.

Configuration

All configuration is optional. It gives you a handy way of setting default values for your message container, the html element you want to wrap your individual messages with, a default view to load your message in, or load a specific view based on a certain message group. If the configuration file is not present nor any views are present, the message library will just output the message without any markup. This might be preferable when passing messages to javascript plugins, like Growl.

what you would like to wrap your individual messages with

$config['message_prefix'] = '<p>';
$config['message_suffix'] = '</p>';

what you would like the container to be of your messages

$config['wrapper_prefix'] = '<div class="message">';
$config['wrapper_suffix'] = '</div>';

the folder to search for partial views with trailing slash

$config['message_folder'] = 'messages/';

the default view to format messages

$config['message_view'] = 'message_view';`

Basic Functions

Set a message

$this->message->set('notice','this is just a notice');

Set an array of messages

$data = array(
	 		'message'=>'this is just a message',
	  		'notice'=>'this is just a notice'
		);

$this->message->set($data);

Return all messages

$messages = $this->message->get();

Return a group of messages

$messages = $this->message->get('notice');

Show all messages

echo $this->message->display();

Show a group of messages

echo $this->message->display('notice');

Automagic functions

If you have a message_folder defined in the config, any message key that matches a view will be autoloaded:

$this->message->set('notice','this is just a notice');

will autoload the file views/message_folder_name/notice_view.php The basic layout for any view looks like this:

foreach ($messages as $message):
	  echo $message;
endforeach;

This gives you freedom to style any message any way you want from within a view.

Installation

Drop the libraries/Message.php file into your application/libraries folder.

Requirements

Only CodeIgniter

Extra

If you'd like to request changes, report bug fixes, or contact the developer of this library, email [email protected]

codeigniter-message's People

Contributors

jeroenvdgulik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.