HMVC - How to load model from other module |
[eluser]yogal[/eluser]
Hi, a really simple question here. I am in Code: modules/guestbook/admin.php and I would like to load model from a diffrient module Code: modules/admin/models/ This method: Code: $this->load->model('someModel', 'someModel'); Code: application/models/ How can i do that with HMCV ? I tried using Modules::find, Modules::load Modules::load_file, but with no result. There has to be a simple way to do this. Thanks in advance.
[eluser]yogal[/eluser]
[quote author="herrkaleun" date="1233274712"]by module you mean a controller?[/quote] Actually, no. What I have: admin module Code: application/ Guestbook module Code: application/ I want to access someModel.php (admin module) from within admin.php controller (guestbook module). Basically someModel is used to store pagination settings in database, and it is located in admin module because through this module I am assaigning settings, then from a whole diffrient module i want to access those settings, and initialize pagination with them ($this->pagination->initialize($config_from_db); I hope this clears things up. Regards, yogal EDIT: I moved the model outside of admin module and placed it in models folder inside application. It might not be the best idea but at least every module using pagination has access to this model now and I am still following DRY.
[eluser]dreamynsx[/eluser]
Yeah I was stuck on this also. I ended up changing the controller code...so you can explicitly pass in the module_path. I think what the code should do is maybe search in present controller, then if not found search in all available module paths for a matching model. Code: public function model($model, $object_name = NULL, $connect = FALSE, $module_path = null)
[eluser]yogal[/eluser]
[quote author="dreamynsx" date="1233837743"]Yeah I was stuck on this also. I think what the code should do is maybe search in present controller, then if not found search in all available module paths for a matching model. [/quote] Yea, thats how matchbox works but unfortunately not HMVC, therefore you cannot for example separate your controllers even further (no sub-folders in controller folder inside module). And thanks for the code I will definitely try it out.
[eluser]Unknown[/eluser]
Maybe for someone it could help. Just use $this->load->model(module/model). For more info, read this https://bitbucket.org/wiredesignz/codeig.../wiki/Home |
Welcome Guest, Not a member yet? Register Sign In |