Welcome Guest, Not a member yet? Register   Sign In
A little help needed with creating a library
#3

[eluser]matrim[/eluser]
[quote author="TheFuzzy0ne" date="1236211343"]You're missing the dollar sign prefix on the call to $this->initialize(). Those typos are a bummer. Wink

My SI CAPTCHA library loads settings from a file. You might be able to learn something from the constructor.

Code:
function Si_captcha($config=array())
{
    $this->CI =& get_instance();
    $this->CI->load->library('session'); // Load the session library in case it's not already loaded.
    
    // Load the default configuration.
    require_once(APPPATH . 'config/securimage'.EXT);
    if (isset($SI_config))
    {
        $this->initialize($SI_config);
        unset($SI_config);
    }
    
    // Now override with the users config if it's been supplied.
    $this->initialize($config);
    // Suh-weeeet...
}
[/quote]

The typo is because I was hurrying to go see Watchmen when typing the sample code and isn't in the normal code Big Grin

So from looking over your code it seems you import the config file with a require_once. But the docs seem to indicate that it's possible to get the config file by just naming it to the same name as the class.

If you have to import it yourself would it be better practice to load the config file with something like $this->CI->config->load('myconfig');


Messages In This Thread
A little help needed with creating a library - by El Forum - 03-04-2009, 11:53 AM
A little help needed with creating a library - by El Forum - 03-04-2009, 12:02 PM
A little help needed with creating a library - by El Forum - 03-04-2009, 05:58 PM
A little help needed with creating a library - by El Forum - 03-04-2009, 08:21 PM
A little help needed with creating a library - by El Forum - 03-05-2009, 01:32 AM
A little help needed with creating a library - by El Forum - 03-05-2009, 02:04 AM
A little help needed with creating a library - by El Forum - 03-05-2009, 02:40 AM
A little help needed with creating a library - by El Forum - 03-05-2009, 02:44 AM
A little help needed with creating a library - by El Forum - 03-05-2009, 03:59 AM
A little help needed with creating a library - by El Forum - 03-05-2009, 04:04 AM
A little help needed with creating a library - by El Forum - 03-05-2009, 04:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB