Search code examples
codeigniterhmvc

CodeIgniter HMVC setup


As per a previous question I'm setting up the HMVC extension for codeigniter. https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home Unfortunately I can't find much in the way of documentation.

I'm confused about how to set up my folders. I've copied the MX folder in third_party over as well as the files in the core folder. After that I created a application/modules folder. From there I want to create a banner slider widget. I've created a subfolder in modules called 'slider' with 'controllers', 'models', and 'views' folders inside of that. Inside my application/modules/slider/controllers/ folder I have a controller called main.php. Inside my application/modules/slider/models/ folder I have a model called slider_model.php. First, is this a proper folder structure for using this? If so here is the issue I'm having.

My welcome.php controller that loads the site looks like this:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

/**
 * Index Page for this controller.
 *
 * Maps to the following URL
 *      http://example.com/index.php/welcome
 *  - or -  
 *      http://example.com/index.php/welcome/index
 *  - or -
 * Since this controller is set as the default controller in 
 * config/routes.php, it's displayed at http://example.com/
 *
 * So any other public methods not prefixed with an underscore will
 * map to /index.php/welcome/<method_name>
 * @see http://codeigniter.com/user_guide/general/urls.html
 */
public function index()
{
    $this->load->view('header');
    $this->load->view('welcome_message');
    $this->load->view('footer');
}
}

 /* End of file welcome.php */
 /* Location: ./application/controllers/welcome.php */

Inside the welcome_message.php view I have the following:

<? echo Modules::run("slider/main/getcontent/"); ?>

Then, inside the main controller I have this:

<?php
class Main extends MX_Controller{
function __construct(){
    parent::__construct();
    $this->load->model('slider/Slider_model','Slider');
}

function getcontent(){
    //
    //echo $this->Slider->test_conn();
    echo "Testing...";
}   
}

?>

As it stands I'm getting this error: Fatal error: Cannot redeclare class CI in /homepages/15/d94236848/htdocs/application/third_party/MX/Base.php on line 57

What am I missing?


Solution

  • As per the comment above I'm reposting my comment as the answer.

    Figured it out. On my welcome.php controller I needed to change it so it extends MX_Controller instead of CI_Controller. I also needed to remove the last slash in the call to the module in welcome_message.php.