0

I'm trying to load multiple libraries in CI but I'm getting an error. Here is my controller

function index()
{                   
    $this->load->library('materials_library/File_Manager');
    $this->load->library('materials_library/Layout');

    $data = array();

    // Send content to template
    $this->layout->view('materials_library/file_manager', $data, 'ml_cms');
}

The error says view is an undefined property. If I comment out the first load->library, I don't get an error. How do I load multiple libraries in CI?

EDIT:

class File_manager
{
    private $CI;

    public function __construct()
    {
        $this->CI =& get_instance();
    }
}
3
  • Sorry I read it incorrectly I thought you were using the default load view, do both of the libraries have a layout object? Commented Jun 5, 2012 at 17:45
  • No. Layout has a layout object and File_manager has a file_manager object. Commented Jun 5, 2012 at 17:46
  • what version of CI are you using? Commented Jun 5, 2012 at 17:53

2 Answers 2

1

To load multiple just put them into one array:

$this->load->library( array('materials_library/File_Manager', 'another/library') );
Sign up to request clarification or add additional context in comments.

5 Comments

I tried that. I think there is a problem with my File_Manager class. When I have the m lowercased, it will load. When I make it upper case, I get an error that I can't redeclare the class. The file is called File_Manager.php. Do I have the naming wrong?
...yes... you seem to if its not loading, always stick to lowercase unless you really need to, if you are on a linux os this will be case sensitive.
Oh, I thought classes were supposed to be capitalized. So to be clear my file name should be file_manager.php and the class should be called file_manager?
It was a naming issue. Solved. Thanks.
@sehummel What fixed it for you? I have the same issue now as well.
0

in codeigniter multiple libraries can be loaded at the same time by passing an array of libraries to the load method, see below example:

$this->load->library(['email', 'table']);

reference: Codeigniter docs for library

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.