Welcome Guest, Not a member yet? Register   Sign In
How to pass HMVC main controller global variables to modules
#1

[eluser]valchazzz[/eluser]
My problem - in HMVC module i can't access defined in main controller "global" variables.

It's not horrible to pass whole ci $this object from main controller to module constructor?

main controller, part of _remap:
Code:
$this->variable = 'test';
// here we pass main ci object to module
$module_html = $this->load->module('welcome', $this);
$module_html->index();

and here is welcome constructor, here i will work with $my variable, to access global variables:
Code:
public $my;
  // here we get $this from main controller
  function  __construct(& $my)  {
    parent::__construct();
    $this->my = $my;
  }

  function index () {
    // here we work with variables from main controller
    echo $my->variable;
    $my->variable = 'test2';
    ...
  }

I see it works, but maybe i just broke HMVC idea...
#2

[eluser]valchazzz[/eluser]
Few days and no answer...




Theme © iAndrew 2016 - Forum software by © MyBB