[eluser]Unknown[/eluser]
I'm not sure how to solve this codeigniter error.
Error: Fatal error: Call to a member function library() on a non-object.
Controller
Code:
public function index()
{
$this->load->helper('url');
$this->load->library('header');
$data['title'] = $this->header->get_page_name();
$data['gutter_value'] = $this->header->get_gutter_value();
$data['js_page'] = $this->header->get_js_page_file();
$data['page'] = $this->header->page;
$data['index_page'] = $this->header->index_page;
$data['nav_names'] = $this->header->nav_names;
$data['banner_img'] = $this->header->get_banner_img();
$this->load->view('includes/header', $data);
$this->load->view('about/about_view');
$this->load->view('includes/footer');
}
Library File
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Header{
var $page = '';
var $index_page = '';
var $nav_names = array();
var $banner_imgs = array();
public function __construct(){
$this -> index_page = 'Writing';
$this -> nav_names = array('Contact', 'About', 'Tools', 'Portfolio', 'Writing');
if($_SERVER['PHP_SELF'] === '/index.php')
{
$this -> page = 'Writing';
}
else
{
$this -> page = end(explode(DIRECTORY_SEPARATOR, $_SERVER['PHP_SELF']));
}
}
function get_page_name()
{
$this->load->library('common');
$page_names = $this->common->page_names();
$title = (array_key_exists($this->page, $page_names) !== false) ? $page_names[$this->page]: '';
if (array_key_exists($this->page, $page_names) !== false)
{
$title .= " | Jason Biondo";
}
return $title;
}
function get_banner_img()
{
$banner_imgs = array('contact.jpg', 'about.jpg', 'tools.jpg', 'portfolio.jpg', 'writing.jpg');
foreach($this->nav_names as $k => $name)
{
if(($this->page === strtolower($name)) OR ($this->uri->segment(1) === strtolower($name)))
{
$banner_img = $banner_imgs[$k];
}
}
return isset($banner_img) ? $banner_img : 'writing.jpg';
}
function get_gutter_value()
{
$gutter_values = array('304', '228', '158', '82', '0');
foreach($this->nav_names as $k => $name)
{
if(($this->page === strtolower($name)) OR ($this->uri->segment(1) === strtolower($name)))
{
$g_value = $gutter_values[$k];
}
}
return isset($g_value) ? $g_value : 0;
}
function get_js_page_file()
{
$page = $this->page;
if (file_exists("./js/pages/${page}.js"))
{
$javascript = "[removed][removed]";
}
return isset($javascript) ? $[removed] FALSE;
}
}
/* End of file header.php */
/* Location: ./application/libraries/header.php */