Welcome Guest, Not a member yet? Register   Sign In
Including non CodeIgniter scripts
#12

[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...aries.html


Quote:Passing Parameters When Initializing Your Class

In the library loading function you can dynamically pass data as an array via the second parameter and it will be passed to your class constructor:

Code:
$params = array('type' => 'large', 'color' => 'red');

$this->load->library('Someclass', $params);

If you use this feature you must set up your class constructor to expect data:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Someclass {

    function Someclass($params)
    {
        // Do something with $params
    }
}

?>
You can also pass parameters stored in a config file. Simply create a config file named identically to the class file name and store it in your application/config/ folder. Note that if you dynamically pass parameters as described above, the config file option will not be available.


Messages In This Thread
Including non CodeIgniter scripts - by El Forum - 05-28-2009, 10:51 AM
Including non CodeIgniter scripts - by El Forum - 05-28-2009, 11:15 AM
Including non CodeIgniter scripts - by El Forum - 05-28-2009, 11:19 AM
Including non CodeIgniter scripts - by El Forum - 05-28-2009, 11:19 AM
Including non CodeIgniter scripts - by El Forum - 05-28-2009, 11:23 AM
Including non CodeIgniter scripts - by El Forum - 05-28-2009, 11:26 AM
Including non CodeIgniter scripts - by El Forum - 05-28-2009, 02:04 PM
Including non CodeIgniter scripts - by El Forum - 05-28-2009, 02:59 PM
Including non CodeIgniter scripts - by El Forum - 05-29-2009, 12:36 PM
Including non CodeIgniter scripts - by El Forum - 06-25-2010, 07:40 PM
Including non CodeIgniter scripts - by El Forum - 06-27-2010, 03:03 PM
Including non CodeIgniter scripts - by El Forum - 06-28-2010, 07:43 AM
Including non CodeIgniter scripts - by El Forum - 06-28-2010, 08:23 AM
Including non CodeIgniter scripts - by El Forum - 06-28-2010, 09:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB