Welcome Guest, Not a member yet? Register   Sign In
Auto loading models inside an HMVC module
#1

[eluser]datdesignguy[/eluser]
Hi Guys,

This is probably a no-brainer, but it's beena while since I've used CI+HMVC.

I'm trying to autoload a model called 'Member' which is inside of my 'members' module.

inside autoload i tried just using 'Member' and 'members/Member' and neither worked.

I've moved the Member model back out to the main model folder for now, but would really like to move it back inside the Members Module to keep my code organized. Any advice?

Thanks,

- Greg
#2

[eluser]Jilani Jidni[/eluser]
Hi Greg

I think the problem with your naming.. please check the user guide for details http://ellislab.com/codeigniter/user-gui...odels.html


[quote author="datdesignguy" date="1241269155"]Hi Guys,

This is probably a no-brainer, but it's beena while since I've used CI+HMVC.

I'm trying to autoload a model called 'Member' which is inside of my 'members' module.

inside autoload i tried just using 'Member' and 'members/Member' and neither worked.

I've moved the Member model back out to the main model folder for now, but would really like to move it back inside the Members Module to keep my code organized. Any advice?

Thanks,

- Greg[/quote]
#3

[eluser]datdesignguy[/eluser]
Hi All,

I'm running into the same problem again. I've lost a bunch of my previous projects so I'm having to start from scratch. I'm recreating an account module for my applications.

inside my application folder I have tested and verified that I have HMVC installed correctly. If I try to load the model from within the account module account controller, it works fine. If I try to load the model from a different module, it works fine.

The only thing not working is when I try to autoload the account/User_model from the config/autoload.php file.

I'd really like to keep this modular, so I'd like to figure out how I can load my account/user_model file using config/autoload.php.

I've read the manual, and followed all naming conventions and it isn't working. Anyone have any ideas?
#4

[eluser]wiredesignz[/eluser]
If you are using a controller extension or normal controller you can add an $autoload array to it.
Code:
class MY_Controller extends Controller
{
    public $autoload = array('model' => array('module/model'));

...




Theme © iAndrew 2016 - Forum software by © MyBB