I downloaded HMVC files from here and set up my CI 3 installation using these file
- Place the MX folder in application/third_party folder
- Place the files in application/core MY_Loader & MY_Router
- Created a folder module in /application.
- Inside module created welcome/controller and welcome/view
- In welcome/controller I copied the default welcome controller and in welcome/view welcome_message.
- Then I created a Template Module with and added below code in it
Then I created module for home, here is how my folder structure looks like
class Template extends MY_Controller { public function __contruct(){ parent:: __contruct(); } public function core_template($data = null) { //$data = new stdClass(); //$data->content = 'home/home_v'; $this->load->view('template/core_template_v', $data); } public function dashboard_template($data = '') { //$data = new stdClass(); $this->load->view('template/dashboard_template_v', $data); } }Folder Structure
application modules template controllers Template.php models views core_template_v.php Home controllers Home.php models viewshome_v.php
Home.php // Controller class Home extends MY_Controller { public function __construct(){ parent::__construct(); $this->load->module('Template'); } public function index() { $data = new stdClass(); $data->content = 'home/home_v'; //$this->slice->view('welcome/welcome', $data); //print_r($data); $this->template->core_template($data); } } ============================================ /* load the MX_Controller class */ require APPPATH."third_party/MX/Controller.php"; class MY_Controller extends MX_Controller { public function __construct(){ parent::__construct(); $this->load->module('Template'); } }I am getting this error:
An uncaught Exception was encountered Type: Error Message: Call to a member function core_template() on null Filename: */modules/home/controllers/Home.php Line Number: 18 Backtrace: File: /*/public_html/index.php Line: 315 Function: require_once
It is working perfectly fine on my local server but when I upload the code to my hosting its throwing this error.