Welcome Guest, Not a member yet? Register   Sign In
CI2 - Is there an issue with loading libs?
#11

[eluser]techgnome[/eluser]
Well, if all you needed was the config info.... try something like this. This is an actual code piece from a library I've built... and it works just fine getting custom config items.
Code:
class Gnome_news
{
    /**
     * CodeIgniter global
     *
     * @var string
     **/
    [b]protected $ci;[/b]

    // $gn_config - stores the configuration settings as loaded from the newsfeed config file
    var $gn_config = array();
    /**
     * __construct
     *
     * @return void
     *
     **/
    public function __construct()
    {
        [b]$this->ci =& get_instance();
        $this->ci->load->config('gnome_news', TRUE);
        $this->gn_config = $this->ci->config->item('gnome_news');[/b]
        $this->ci->load->helper('date');
        $this->ci->load->helper('url');
        $this->ci->load->model('gnome_news/gnome_news_model');
    }

I've bolded the important bits... In short, I get the CI super var instance, and use it in the constructor to load the config and other items. When loading the config, pass the TRUE parameter to load it into it;'s own array, then use that to load it into an array inside the library.

-tg


Messages In This Thread
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 01:41 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 02:38 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 02:40 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 03:01 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 03:05 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 03:10 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 03:16 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 05:51 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 05:56 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 06:38 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 08:33 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 08:38 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 08:49 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-23-2010, 10:05 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-24-2010, 12:16 PM
CI2 - Is there an issue with loading libs? - by El Forum - 10-26-2010, 03:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB