Welcome Guest, Not a member yet? Register   Sign In
Using HMVC's MX_Controller, Cannot recognize any methods when using &get;_instance
#1

[eluser]goFrendiAsgard[/eluser]
Hi, I have a controller in /application/core

/application/core/CMS_Controller.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require APPPATH."third_party/MX/Controller.php";

class CMS_Controller extends MX_Controller {

    public function __construct() {
        parent::__construct();
    }

    public function show_something() {
        echo "something shown";
    }
}

I have another controller in a module (/modules/my_module/controllers/controller.php) which extended from CMS_Controller

/modules/my_module/controllers/controller.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Controller extends CMS_Controller {

    public function index() {
        $this->load->view('view');
    }
}

And, in view.php (/modules/my_module/views/view.php) I do this:
/modules/my_module/views/view.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$ci =& get_instance();
echo $ci->show_something();
?>

And I get this error:
Quote:Fatal error: Call to undefined method CI:Confusedhow_something() in /home/gofrendi/public_html/No-CMS/modules/my_module/views/view.php on line 3

It will works if I don't use MX_Controller and using this instead:
/application/core/CMS_Controller.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

//require APPPATH."third_party/MX/Controller.php";

class CMS_Controller extends CI_Controller {

    public function __construct() {
        parent::__construct();
    }

    public function show_something() {
        echo "something shown";
    }
}

Anybody know what's wrong here?




Theme © iAndrew 2016 - Forum software by © MyBB