application/core
の子コントローラからコアコントローラクラスをapplication/controllers
にコールしようとしています。私はHome
コントローラhome.php
をapplication/controllers
に、Public_Controller
をapplication/core
に拡張しています。私home.php
は、このようなものです:コアフォルダ内のCodeigniterがコアクラスを呼び出せません
<?php
class Home extends Public_Controller
{
public $data = array(
'page' => 'home',
'main_view' => 'home'
);
public function index()
{
$this->load->view($this->layout, $this->data);
}
}
、私は上記のコードから
<?php
class Public_Controller extends MY_Controller
{
// Layout untuk "Publik"
public $layout = 'layout';
}
をpublic_controller.phpている、MY_Controllerもコアにあります。ここでは、コード
<?php
class MY_Controller extends CI_Controller
{
public function __construct()
{
parent::__construct();
// Autoload model.
$model = strtolower(get_class($this));
if (file_exists(APPPATH . 'models/' . $model . '_model.php')) {
$this->load->model($model . '_model', $model);
}
}
}
はそうだが、要約すると、私はapplication/core
でpublic_controller
を拡張し、public_controller
はそのまたapplication/core
でmy_controller
を拡張application/controllers
のコントローラhome
を持っています。 は、私はすでにこのコード
function __autoload($class)
{
if(strpos($class, 'CI_') !== 0)
{
@include_once(APPPATH . 'core/'. $class . EXT);
}
}
を追加することにより、設定/ config.phpのを修正私はこのhttps://philsturgeon.uk/codeigniter/2010/02/08/CodeIgniter-Base-Classes-Keeping-it-DRY/
から参照することによってコントローラに、ベースのコントローラを接続することができます。しかし、それはまだ動作していません。それを言って
私はこの問題を解決するために何かできますか? ありがとう