c_pattle Posted December 28, 2011 Share Posted December 28, 2011 I have a problem where in a controller constructor I can load the codeigniter libraries such as session and cart but I can never load any libraries that I've written. Everytime I do it says that it is undefined. Does anyone know what might be causing this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/253943-codeigniter-library-problem/ Share on other sites More sharing options...
trq Posted December 28, 2011 Share Posted December 28, 2011 Hmmm. let me get my crystal ball out.... Quote Link to comment https://forums.phpfreaks.com/topic/253943-codeigniter-library-problem/#findComment-1301818 Share on other sites More sharing options...
c_pattle Posted December 28, 2011 Author Share Posted December 28, 2011 Sorry. So for example if I do class Homepage extends CI_Controller { function Homepage() { parent::__construct(); $this->load->library('layout'); } } The library doesn't seem to load because I can't access any of the method in that libary. But if I was to load the library in another function that wasn't the contoller it works fine Quote Link to comment https://forums.phpfreaks.com/topic/253943-codeigniter-library-problem/#findComment-1301821 Share on other sites More sharing options...
ignace Posted December 28, 2011 Share Posted December 28, 2011 $this->load->library('layout'); if (!isset($this->layout)) $this->layout = get_instance()->load->library('layout'); var_dump($this->layout); What does this tell you? Quote Link to comment https://forums.phpfreaks.com/topic/253943-codeigniter-library-problem/#findComment-1301839 Share on other sites More sharing options...
sKunKbad Posted December 29, 2011 Share Posted December 29, 2011 class Homepage extends CI_Controller { public function __construct() { parent::__construct(); // Assuming layout.php or Layout.php is located in /application/libraries/ $this->load->library('layout'); } public function index() { $whatever = $this->layout->some_method(); } } Quote Link to comment https://forums.phpfreaks.com/topic/253943-codeigniter-library-problem/#findComment-1302358 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.