Welcome Guest, Not a member yet? Register   Sign In
Do this code for most functions
#6

[eluser]CroNiX[/eluser]
From within libraries, to access CI, you need to bring CI into the library or you will get that error because it can't find the object.
Code:
class Something {
  private $CI;  //variable to hold CI object

  function __construct($settings = array())
  {
    parent::__construct($settings);

    $this->CI =& get_instance(); //bring the CI object into your library
  }

  public function check_login()
  {
    //Use CI object in your library, $this->CI instead of just $this like in controllers/etc.
    if ($this->CI->ipbwi->member->isLoggedIn())
    {
      //logged in
    }
    else
    {
      //not logged in
    }
  }
}


Messages In This Thread
Do this code for most functions - by El Forum - 04-23-2012, 10:31 AM
Do this code for most functions - by El Forum - 04-23-2012, 11:23 AM
Do this code for most functions - by El Forum - 04-23-2012, 11:53 AM
Do this code for most functions - by El Forum - 04-23-2012, 11:56 AM
Do this code for most functions - by El Forum - 04-23-2012, 12:39 PM
Do this code for most functions - by El Forum - 04-23-2012, 12:46 PM
Do this code for most functions - by El Forum - 04-23-2012, 01:01 PM
Do this code for most functions - by El Forum - 04-23-2012, 01:26 PM
Do this code for most functions - by El Forum - 04-23-2012, 01:34 PM
Do this code for most functions - by El Forum - 04-23-2012, 01:54 PM
Do this code for most functions - by El Forum - 04-23-2012, 02:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB