An open API service indexing awesome lists of open source software.

https://github.com/joshuachinemezu/ci-toastr

Codeigniter package for integrating javascript toastr into your web applications
https://github.com/joshuachinemezu/ci-toastr

ci-toastr codeigniter codeigniter-library codeigniter-toastr javascript toast-notifications toastr

Last synced: 13 days ago
JSON representation

Codeigniter package for integrating javascript toastr into your web applications

Awesome Lists containing this project

README

        

# ci-toastr

[![Build Status](https://travis-ci.org/joshuachinemezu/ci-toastr.svg?branch=master)](https://travis-ci.org/joshuachinemezu/ci-toastr)

A CodeIgniter Library to integrate javascript toastr

Have you ever been in a situation that you need to send timed notifications to your client view, notifications that you want to expire within a certain period of time.

PHP(Codeigniter) allows that feature by flashing messages to the session but in most cases, the issue is to display such messages in a fashionable and user friendly way.
Wooooh I got you on this. XD

Example Scenario:
You only just want to display the message with custom colors pertaining to each message
This library will help you in runing such query in a very easy to use interface.

## Requirements

- PHP >= 5.2
- CodeIgniter Application
- Valid loading of the session library

## Installation

The easiest way to install this is to clone the repo in your local disk.
Then copy the src/Toaster.php file in your application/libraries Folder.

You can then load it like any other library

$this->load->library('toastr');

Or if you are using composer run

composer require joshuachinemezu/ci-toastr

Create a file in your application/views folder and name it "alert.php". Paste the following code in it.


<?php if ($this->session->flashdata('success')) {?>
toastr.success("<?php echo $this->session->flashdata('success'); ?>");
<?php } else if ($this->session->flashdata('error')) {?>
toastr.error("<?php echo $this->session->flashdata('error'); ?>");
<?php } else if ($this->session->flashdata('warning')) {?>
toastr.warning("<?php echo $this->session->flashdata('warning'); ?>");
<?php } else if ($this->session->flashdata('info')) {?>
toastr.info("<?php echo $this->session->flashdata('info'); ?>");
<?php }?>

---

Ooooh it's getting complicated right? Don't worry one more step and we are done here

Create another file in your application/views folder and name it flash.php (Just for consistency but you can name it anything if you know your way around here). Paste the code below in it









load->view('alert');
?>


Yeah we are through with installation. lol

## Usage

Using it is very easy

In your controller after a task is completed, you can use any of the codes below in regards to the code flow

-- for successful message

$this->toastr->success('Your account was created successfully');

-- for info message

$this->toastr->info('Please check your mail to activate account');

-- for warning message

$this->toastr->warning('Email is required');

-- for error message

$this->toastr->error('Error in creating account');

------- In the controller where you want the session(toastr) message to display, add
--------the code below:

$this->load->view('flash');

-----\***\* flash is the name of the file you created in application/views folder \*\*\***----

Using the code above will display a toastr message

You see very easy to use