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
- Host: GitHub
- URL: https://github.com/joshuachinemezu/ci-toastr
- Owner: joshuachinemezu
- License: other
- Created: 2018-06-21T08:39:20.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-29T16:14:31.000Z (over 6 years ago)
- Last Synced: 2025-04-13T02:38:00.671Z (13 days ago)
- Topics: ci-toastr, codeigniter, codeigniter-library, codeigniter-toastr, javascript, toast-notifications, toastr
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 15
- Watchers: 2
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ci-toastr
[](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. XDExample 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