1

I am using HMVC and Template library (by Phil Sturgeon). The problem occur when I use Modules::run in my code:

$this->template->title("Some title")->set_partial('header', 'showmessage')->build('showanothermessage', $data);

and in showmessage.php partial view:

echo Modules::run("goodbye");

The error page appear with:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: GoodBye::$agent

Filename: libraries/template.php

Line Number: 122

Fatal error: Call to a member function is_mobile() on a non-object in D:\Binh\wamp\www\codeigniter\application\libraries\template.php on line 122

How to fix this problem. Thanks in advance.

Update My goodbye controller:

class GoodBye extends MY_Controller{
        function __construct(){
            parent::__construct();
        }
        function Index(){ echo "Goodbye"; }
}

My MY_Controller:

class MY_Controller extends CI_Controller{
    function __construct(){
        parent::__construct();
        // default layout
        $this->template->set_layout("home_layout");
    }
}

My autoload file:

$autoload['packages'] = array();
$autoload['libraries'] = array('database','session','template');
$autoload['helper'] = array();
$autoload['config'] = array();
$autoload['language'] = array();
$autoload['model'] = array();
4

1 回答 1

0

我已将 MY_Controller 更改为:

class MY_Controller extends MX_Controller{
    function __construct(){
        parent::__construct();
        // default layout
        $this->template->set_layout("home_layout");
    }
}

有效!

于 2012-03-16T05:03:56.703 回答