Here is my code for custom library
<?php
//$ci =& get_instance();
class Menu extends CI_Controller{
function loadViews($viewName = "", $headerInfo = NULL, $pageInfo = NULL, $footerInfo = NULL){
$this->load->view('includes/header', $headerInfo);
$this->load->view($viewName, $pageInfo);
$this->load->view('includes/footer', $footerInfo);
}
}
and in my controller, calling this loadViews like this
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require APPPATH . '/libraries/Menu.php';
class Login extends CI_Controller
{
public function __construct()
{
parent::__construct();
//$this->load->database();
$this->load->model('Login_model');
$this->load->library('session');
$this->load->library('menu');
}
public function abc()
{
$this->menu->loadViews("staff_form", NULL, NULL, NULL);
}
What i have tried so for: load library in Autoload, create $CI
instance and tried but nothing worked
should be placed within your
application/libraries/Menu.php
May be, You have to take a look at Output class docs also.
However , I recommend loading views from your controller. This is a unwanted, extra work. You can create a function within the controller instead of creating a new library.