Adding Notifications
Oi uses the php magic method __call() to add any number of different alert types to your application.
$this->oi->add_{type}()
This method will add an alert to Oi. The first parameter is the alert contents (string).
$this->oi->add_message('Hello World');
Will create the following html notification
<p class="oi message">Hello World</p>
The second parameter can be used to add any extra attributes to the alert. Pass an associative Array.
$attr = array('id' => 'error-127', 'title' => 'You really should fix this...');
$this->oi->add_error('Oops, something went wrong', $attr);
// will create the following html notification
<p class="oi error" id="error-127" title="'You really should fix this..." >Oops, something went wrong</p>
The four basic alert types are:
- message - $this->oi->add_message()
- success - $this->oi->add_success()
- warning - $this->oi->add_warning()
- error - $this->oi->add_error()
You are not limited to these and the type may be any string you choose. You can even add extra classes to your alerts and include HTML in you alert string.
$attr = array('class' => 'my-class');
$this->oi->add_somereallystupidlylongalertname('<a href="mylink.html">Click</a> me', $attr);
// will create the following html notification
<p class="oi somereallystupidlylongalertname my-class" ><a href="mylink.html">Click</a> me</p>