I have an issue with my codeigniter helper.
This is my controler that calls a view:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Login extends CI_Controller {
function __construct() {
parent::__construct();
}
function index() {
$this->load->view('inc/header');
$this->load->view('login_view');
$this->load->view('inc/footer');
}
}
This works fine, but I have more then one controler with multiple functions that can call a view.
so I thought I make a helper:
function view($site) {
$this->load->view('inc/header');
$this->load->view($site);
$this->load->view('inc/footer');
}
When I call this helper like this:
view('login_view');
I get this error:
> Fatal error: Using $this when not in object context in C:\.....\application\helpers\custom_helper.php on line 23
line 23 =
$this->load->view('inc/header');
What's wrong with this code?