[eluser]Aaron Wallentine[/eluser]
Hello,
The CodeIgniter documentation states thusly:
Quote:Passing Parameters When Initializing Your Class
In the library loading function you can dynamically pass data via the second parameter and it will be passed to your class constructor:
$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.
Anyone know more specifics on this? I tried this out, making a file in application/config identically named to my library's file name, and added some parameters there; but how are they supposed to be named, and how do you access them from the library? I can't seem to find any documentation on this.
Since it doesn't say anything, I assumed that the parameters in the config file would be available as an array passed into the constructor, but that doesn't seem to be the case.
I tried naming my parameters in the config file as members of a $config array, as well as an array named after my class. But neither shows up when the class constructor is called.
Anyone have anything on this?
Thanks