0

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.

0

1 Answer 1

-1

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

Sign up to request clarification or add additional context in comments.

1 Comment

HMVC is Hierarchical Model View Controller. You can developed in ci by using module HMVC has its own controller,view and model.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.