Welcome Guest, Not a member yet? Register   Sign In
CI 2.1 + HMVC. Passing data to instance from helper does not work
#1

[eluser]Ki[/eluser]
Have been working with CI for over 5 years and decided to move into HMVC. So far it has been a smooth transition, but I cannot wrap my head around as to why my helper stopped passing data to the CI instance.

Summary: Prior to HMVC I was using helper to store notifications to the user in array. This is what I have in helper:
Code:
function set_msg($msg,$type="success"){
    $CI =&get;_instance();
    $CI->data['messages'][$type][]='<li>'.$msg.'</li>';
    d($CI->data['messages']);
}

Note: ";" in &get;_instance() was added by the post.

By having it set up like this, I could simply call set_msg('Wrong Password','error') in any controller/model/view and it will be captured in $this->data['messages']) array .

I have also a master controller called MY_Controller that handles all of the functionality that happens across all pages, such as login check etc.
To keep it simple, when I call the set_msg() helper function in one of my models, I am not able to see the messages when i do printf($this->data); right before I load my view.
It used to work before moving to HMVC, but now my gut feeling is that helper is not recording the messages in the right instance.

Here is how MY_Controller is set up:
Code:
class MY_Controller extends MX_Controller {
    
    public $data;

Any solution is appreciated.
#2

[eluser]goFrendiAsgard[/eluser]
I've got the same problem here:
http://ellislab.com/forums/viewthread/224908/

I've also post it in stackoverflow with no luck.




Theme © iAndrew 2016 - Forum software by © MyBB