HMVC / MX_Controller / Undefined property - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: HMVC / MX_Controller / Undefined property (/showthread.php?tid=19006) |
HMVC / MX_Controller / Undefined property - El Forum - 05-25-2009 [eluser]Mark75[/eluser] Hi, i just installed HMVC in a blank Codeigniter Installation. Everything worked fine until i wanted to include my auth-Controllers. Perhaps someone has an idea what is going wrong? I created the file MX_Controller in /libraries with the following source: Code: <?php if( ! defined('BASEPATH') ) exit('No direct script access allowed'); This is my welcome-Controller (already working in module-directory) Code: <?php When i reload my page i get the following errors: Code: Undefined property: CI::$data I think that is has something to do with the __get function in Controller.php and my PHP-Version (currently 5.2). I just cant figure out what? $this->data->user in Public_Controller is FALSE when no user is logged in. Any help would be greatly appreciated Mark HMVC / MX_Controller / Undefined property - El Forum - 05-25-2009 [eluser]wiredesignz[/eluser] You must add the $data class variable to your Public_controller class. PHP5 is looking for a $this->data object so that it can add the $user variable. If the $data object doesn't exist PHP5 then uses the overload method to try to __get $data from the CI application object. HMVC / MX_Controller / Undefined property - El Forum - 05-25-2009 [eluser]Mark75[/eluser] Thank you for your fast reply! Now my Controller looks like this: Code: class Public_Controller extends Controller { Mark HMVC / MX_Controller / Undefined property - El Forum - 05-25-2009 [eluser]wiredesignz[/eluser] [quote author="Mark75" date="1243268621"]No errors, i hope that is the way you meant it.[/quote] Yes and no. Yes the var needs to be defined But... You refer to the $data variable as an object ($this->data->user) but in fact you define it as a simple variable and PHP covers your ass by casting for you. If $data is not really an object then it should be used as an array. ($this->data['user']) HMVC / MX_Controller / Undefined property - El Forum - 05-25-2009 [eluser]Mark75[/eluser] Ok, thanks for clarification. This should be better: (?) Code: class Public_Controller extends Controller { Regards Mark HMVC / MX_Controller / Undefined property - El Forum - 05-27-2009 [eluser]Mark75[/eluser] Hi again, it would be great if you could help me one more time with a small problem... My Public_Controller (in MX_Controller.php) now look like this: Code: class Public_Controller extends Controller { Code: Undefined property: CI::$data Any help is greatly appreciated. Thanks mark HMVC / MX_Controller / Undefined property - El Forum - 06-02-2009 [eluser]Mark75[/eluser] Sorry for posting again, but i'm still fighting with the same problem (see post above). $this->data is available in my view files without problem, but Profiler.php says Code: Undefined property: CI::$data Code: $this->CI =& get_instance(); Thanks for any hints. Regards Mark HMVC / MX_Controller / Undefined property - El Forum - 06-02-2009 [eluser]wiredesignz[/eluser] When using Modular Extensions 5.2 the controller and CI are separate objects so the profiler (using CI) will not see a controller class variable unless you specifically pass a reference. Maybe something like this in your controller constructor Code: CI::instance()->data =& $this->data; HMVC / MX_Controller / Undefined property - El Forum - 06-02-2009 [eluser]Mark75[/eluser] Ok, that works. Thank you! HMVC / MX_Controller / Undefined property - El Forum - 03-10-2012 [eluser]Unknown[/eluser] good eve I have a similar problem I get this errors A PHP Error was encountered Severity: Notice Message: Undefined property: CI::$data Filename: libraries/Controller.php Line Number: 354 public function __get($var) { return CI::$APP->$var; } } and A PHP Error was encountered Severity: Notice Message: Indirect modification of overloaded property Bs::$data has no effect Filename: controllers/bs.php Line Number: 41 function add(){ $this->load->library('form_validation'); $this->data['custom_error'] = ''; the lines of codes are below. please anyone of help I am using codeigniter 1.7.2 and I got the codes for crud generator which was created with codeigniter 2.0.2 |