HMVC not work in CI 3.1.3 But works 3.1.2 |
Hello,
I am not sure what has changed but can not seem to get HMVC to work in Codeigniter 3.1.3 works fine 3.1.2 I had a look here http://www.codeigniter.com/user_guide/ch...-for-3-1-3 Could not see anything effect it? Any ideas?
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
01-09-2017, 08:26 PM
(This post was last modified: 01-09-2017, 08:51 PM by ronelb. Edit Reason: more info added )
This was posted here https://forum.codeigniter.com/thread-670...#pid339890, re: HMVC not working on CI 3.1.3.
(01-09-2017, 05:22 PM)ivantcholakov Wrote: @michaelh99 I created a CI 3.1.3 project with HMVC, run it and got the error: "Fatal error: Call to undefined method MY_Loader::_ci_object_to_array() in D:\xampp\htdocs\DTCIS\application\third_party\MX\Loader.php on line 300" I changed the "_ci_object_to_array()" as suggested by @ivantcholakov and it worked! Hope that helps.
Share what you know,
Learn what you don't
That sounds like an issue in the HMVC package, and not in CI 3.1.3, though 3.1.3 may have changed something.
You might want to consider a PR to the HMVC project!
There seems to be an issue in CI 3.1.3 with the _ci_prepare_view_vars() function inside CodeIgniter/system/core/Loader.php preventing objects being passed to views.
I'm not sure but this might be related to this issue. Edit: Removed link. Thanks @ivantcholakov for the details
Yes, it works.. application/core/MY_Loader.php
<?php (defined('BASEPATH')) OR exit('No direct script access allowed'); /* load the MX_Loader class */ require APPPATH."third_party/MX/Loader.php"; class MY_Loader extends MX_Loader { /** Load a module view **/ public function view($view, $vars = array(), $return = FALSE) { list($path, $_view) = Modules::find($view, $this->_module, 'views/'); if ($path != FALSE) { $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths; $view = $_view; } return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => ((method_exists($this,'_ci_object_to_array')) ? $this->_ci_object_to_array($vars) : $this->_ci_prepare_view_vars($vars)), '_ci_return' => $return)); } }
(01-29-2017, 09:10 PM)luckymahrus Wrote: Yes, it works.. application/core/MY_Loader.php Yes it is !! ![]() ![]()
Hi all I'm having a heck of a time getting hmvc to work. I made the replacement of "_ci_object_to_array" to "_ci_prepare_view_vars" and that corrected the php error, but I'm still getting a 404 page not found for all my module controllers. Is there a change to the config file that I need or something?
Wow, no sooner did I post this, then I read on another forum to be mindful of the pesky "first letter capitalized for controllers and models, but not for views" rule of thumb. I stopped doing that at some point, but apparently with hmvc you need to follow that again.
With the change from this thread and the properly named controllers and models, mine is working again. |
Welcome Guest, Not a member yet? Register Sign In |