hi, has every one try the latest code from codeigniter reactor 2011 04 22 ?
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI::$_ci_cached_vars
Filename: MX/Loader.php
Line Number: 265This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
January 29, 2011 1:58am
Subscribe [99]#46 / Apr 22, 2011 12:01am
hi, has every one try the latest code from codeigniter reactor 2011 04 22 ?
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI::$_ci_cached_vars
Filename: MX/Loader.php
Line Number: 265#47 / Apr 22, 2011 5:34am
All the properties in the core Loader library are now protected, HMVC doesn’t work because of this.
I know changing the core is not a good solution, but the only 2 solutions are:
1. Go to an older CI version, 2.0.2 should work fine
2. Change the Loader library in system/core/Loader.php:
public $_ci_ob_level;
public $_ci_view_paths = array();
public $_ci_library_paths = array();
public $_ci_model_paths = array();
public $_ci_helper_paths = array();
public $_base_classes = array(); // Set by the controller class
public $_ci_cached_vars = array();
public $_ci_classes = array();
public $_ci_loaded_files = array();
public $_ci_models = array();
public $_ci_helpers = array();
public $_ci_varmap = array('unit_test' => 'unit',
'user_agent' => 'agent');It’s a quick and dirty fix, but it works 😉
#48 / Apr 25, 2011 4:49am
Pushed an update to Bitbucket to resolve $_ci_cached_vars error. Further updates to follow.
#49 / Apr 25, 2011 6:15am
Tried to use your last update and I got these errors:
Fatal error: Access level to MX_Loader::_ci_load() must be public (as in class CI_Loader) in E:\web\ci_test\application\third_party\MX\Loader.php on line 378turning _ci_load to public produces
Fatal error: Access level to MX_Loader::_ci_get_component() must be public (as in class CI_Loader) in E:\web\ci_test\application\third_party\MX\Loader.php on line 378And if _ci_get_component is turned to public everything seems to work as expected in a vanilla installation.
#50 / Apr 25, 2011 6:45am
gonna try new code after i complete a module i am working on.
#51 / Apr 25, 2011 6:46am
@osci, Yes thanks, that will be a Reactor and Core CI version conflict too. Reactor is using protected methods. I will update again to use public methods.
#52 / Apr 25, 2011 8:18am
Thanks for the info wiredesignz.
I am basically using core for my commercial projects.
I’ll check it there too and repost.
The vanilla test was on reactor since I wanted to check my projects on reactor too.
I know I might be asking too much but could we have another branch for reactor and another for core?
Thanks again for your contributions.
#53 / Apr 25, 2011 4:13pm
Hi wiredesignz, was I wrongly extending MX_Lang or is there not a native way to extend that with HMVC? Also, is there a bug with $this->router->fetch_module() not always returning the correct module in different contexts?
#54 / Apr 25, 2011 10:00pm
Hi! I’m starting to learn HMVC and I really think that it can do wonders. It might be what I need to actually create an admin-member-non-member website.
I’m just running encountering a problem. It seems there’s a problem with calling HMVC from the view. I’m currently following the Net Tuts HMVC: an introduction and application. Let me explain:
Here are the functions:
THE CONTROLLER FUNCTION UNDER “LOGIN” MODULE:
function cp()
{
if( $this->session->userdata('username') )
{
// load the model for this controller
$this->load->model('membership_model');
// Get User Details from Database
$user = $this->membership_model->get_member_details();
if( !$user )
{
// No user found
return false;
}
else
{
// display our widget
$this->load->view('user_widget', $user);
}
}
else
{
// There is no session so we return nothing
return false;
}
}and
THE VIEW UNDER THE “SITE” MODULE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
</head>
<body>
<?php echo modules::run('modules/login/cp');?>
<h2>Welcome Back, <?php echo $this->session->userdata('username'); ?>!</h2><p> <br />
This section represents the area that only logged in members can access. <br />
</body> <br />
</html>THE PROBLEM:
I can’t seem to call cp() from the view using <?php echo modules::run(‘modules/login/cp’);?>. It doesn’t produce the user_widget. If I change the function called in the view (i.e. <?php echo modules::run(‘modules/login/RANDOMFUNCTION’);?>), it don’t get an error.
If I remove the “modules” from the path (as in the original code in the article - <?php echo modules::run(‘login/cp’);?>), I get an error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Login::$session
Filename: controllers/login.php
Line Number: 91
Is there something wrong with the code? I followed the guide to the letter except when I had to edit the module::run call from module::run(‘login/cp’) to module::run(‘modules/cp’) to follow the format specified:
Format: modules::run(‘module/controller/action’, $param1, $param2, .., $paramN);
#55 / Apr 25, 2011 10:02pm
@wilso417, MY_Lang should be located in application/core and should extend MX_Lang. The error with CI_Controller needs to be resolved as a separate issue.
MX_Router::fetch_module() returns the name of the last module controller loaded.
#56 / Apr 25, 2011 10:06pm
@eldrinofsoalim, Don’t use the word “modules” use the name of your module. The error with Login::$session needs to be resolved as a separate issue.
#57 / Apr 26, 2011 5:05pm
I see, thanks wiredesignz.
Is there any easy way to return or have fetch_module() return the last module being ‘used’ and not just loaded?
#58 / Apr 29, 2011 12:09pm
Just pulled the latest changes for Reactor. I had to add another public var to MX/Loader.php
public $_ci_classes = array();#59 / May 04, 2011 4:42pm
Hi Wiredesignz, any way I can have the HMVC modules load when calling them from a view partial, but have them ignore the url? Ideally configurable per module.
#60 / May 04, 2011 5:38pm
@Mr. Pickle, Use modules::run(‘module/controller/method’) to load a module from a view partial and add the _remap() method to a controller where you can manage calls from the URL.
class Partial_controller extends MX_Controller
{
public function _remap() //trap calls from the URL
{
show_404(); //show page not found
}
public function show_view()
{
$this->load->view('what_ever');
}
}