[eluser]Emass[/eluser]
[quote author="jedd" date="1259430358"]
Are we allowed to know what the error is?
[/quote]
Certainly. I get a fatal error, Undefined class constant 'Page'.
So I now have a class named 'MY_Controller.php' placed in the libraries folder containing the following code.
Code:
class MY_Controller extends Controller {
public $defaultPageid = 1;
private $pageid;
private $title;
private $login = false;
function __construct() {
parent::Controller;
$session = array(
'id' => '1'
);
//$this->session->set_userdata($session);
$this->setTitle();
}
function getLogin(){
return $this->login;
}
function setTitle() {
$this->title = 'Title...';
}
function getTitle() {
return $this->title;
}
function setPageid($id) {
$this->pageid = $id;
}
function getPageid() {
return $this->pageid;
}
}
$main = new MY_Controller;
Just how do I get this linked to the code in the 'page' class? My guess is that the $main = new MY_Controller; is not working, but how else do I get the page class to talk with 'My_Controller'?
I now get the following error: Fatal error: Undefined class constant 'Controller' in C:\xampp\htdocs\codeigniter\application\libraries\MY_Controller.php on line 10
Line 10 is the parent::Controller();
This is the code of Page, once more.
Code:
class Page extends Controller {
function __construct() {
parent::Controller();
global $main;
$main->setPageid($this->uri->segment(3, $main->defaultPageid));
}
function index() {
global $main;
$this->load->model('default_queries');
$data['menu'] = $this->default_queries->getMenu();
$data['content'] = $this->default_queries->getContent($main->getPageid());
$data['title'] = $main->getTitle();
$this->load->view('index', $data);
}
function cms() {
global $main;
//var_dump($main->getLogin());
$this->load->model('default_queries');
$data['menu'] = $this->default_queries->getMenu();
$data['content'] = $this->default_queries->getContent($main->getPageid());
$data['title'] = $main->getTitle();
$this->load->view('index', $data);
}
}