user1256614
user1256614

Reputation: 1

How to pass parameters to module constructor when calling a HMVC module in CodeIgniter?

I just want to know on how to pass parameters in module constructor?

Here is the code that is wrote but its not functioning well.

//Here is the main controller

class Main extends MX_Controller
{
      public function _construct()       {
            parent::
_construct();
      }

 public function index()
 {

  // sample parameter
    $aparam = array(
      'param1' => 'param value1',
      'param2' => 'param value2'
    );

      $this->load->module('dashboard',$aparam);
  }

}

  // Here is "dashboard" module controller

  class Dashboard extends MX_Controller
  {

      public function __construct($aparam)
      {
            //output param value
            // want to get this value
             echo $aparam['param1'];
            echo $aparam['param2'];
     }
}

Please help. thanks.

Upvotes: 0

Views: 896

Answers (1)

hypervisor666
hypervisor666

Reputation: 1275

Ok, so just to clarify, I don't know what "HMVC" stands for but I did notice that if you are trying to use the codeigniter framework then when you create a controller class you must extend the "CI_Controller" class not the "MX_Controller".

Here is a reference page in the codeigniter manual: http://codeigniter.com/user_guide/general/controllers.html

If you are trying to create a stand alone class that interacts with your code somehow, Codeigniter allows for this via "libraries". A library is just a class.

Here is the reference page in the codeigniter manual: http://codeigniter.com/user_guide/general/creating_libraries.html

Upvotes: -1

Related Questions