Skip to content

raylight75/Codeigniter-Currency-Converter-Helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codeigniter-currency-converter V 1.0.0

A Codeigniter Helper to convert your price from database from a currency to another

Background

Is very frequently that inside your sites you need to convert your price from a currency to another. You need to have valid database connection and tables to use this helper.

Simple Usage:

If helper is loaded in autoload you can use it in evere view file like:

<?php echo currency($row->price);?> <?php echo label();?>

where we pass data from database in helper function like in this example object $row->price and thath call helper function to display currency label from session. Use sql file to see table structure.

First set link in your site with

<a href="<?php echo base_url() ?>home/set_currency/usd or eur or bgn">

Then simply set the name of the currency in session data like

$this->session->set_userdata('set_currency', $currency);

You need function in some controller to set data - Example:

public function set_currency($currency = "")
   {
       $currency = ($currency != "") ? $currency : "usd";
        $this->session->set_userdata('set_currency', $currency);
        redirect(base_url());
   }

In the end just call helper in view like:

<?php echo currency($row->price);?> <?php echo label();?>

Requirements

CodeIgniter 2.x, 3.x PHP 5.2 or gretaer

Installation

Drag and drop the currency_helper.php in into your application directories. Load it from your application/config/autoload.php using:

$autoload['helper'] = array('currency');

About

Codeigniter Currency Converter Helper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages