Lonare
Lonare

Reputation: 4703

CodeIgniter 3.x.x + WireDesignz HMVC - Call to a member function core_template() on null

I downloaded HMVC files from here and set up my CI 3 installation using these file

  1. Place the MX folder in application/third_party folder
  2. Place the files in application/core MY_Loader & MY_Router
  3. Created a folder module in /application.
  4. Inside module created welcome/controller and welcome/view
  5. In welcome/controller I copied the default welcome controller and in welcome/view welcome_message.
  6. Then I created a Template Module with and added below code in it
  7. 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
       views
    

    home_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.

Upvotes: 0

Views: 124

Answers (0)

Related Questions