2

I'm trying to implement modular extensions into a codeigniter 2 setup but am having a few problems. I followed the installation instructions on the wiki and everything was working fine. Then I started to play around a bit and try and use it. All I did was create a new module called users with the required folders and added a model class called users_m. I then tried to load this from my welcome module controller. According to the wiki this should be very straightforward. I simply added this line

$this->load->model('users/users_m');

to the constructor of my welcome controller.

Unfortunately at this point I get the white screen of death.

So I tried something else. This time I removed the load model line and added

$this->output->enable_profiler(TRUE);

This time I got the welcome page displayed and I got the profiler, but at the top of the page I got this error:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI::$profiler

Filename: MX/Loader.php

Line Number: 145

I don't know if these two tries are related or not, but there's obviously something not right with my setup. Could someone point me in the right direction?

MartinStettner
  • 28,719
  • 15
  • 79
  • 106
musoNic80
  • 3,678
  • 9
  • 40
  • 48

2 Answers2

3

If you accessing the model from the controller in the same module, you can load it using just:

$this->load->model(‘user_m’);

You only have to do $this->load->model(‘module/model_name’); when your cross loading between modules.

Just to make sure, your model is located here right?

application/modules/users/models/users_m.php

As for the profiler error:
1) Have you done installation step 5 and put the Modular Extensions core files into application/core?
2) Do you have the latest version of HMVC? There have been updates to mx/loader.php in the last couple days.

Ps. great tutorial on HMVC: http://net.tutsplus.com/tutorials/php/hvmc-an-introduction-and-application/

Mitchell McKenna
  • 2,267
  • 15
  • 17
  • Well, I'm not sure exactly what the problem was, but it might well have been down to the updates you mentioned. I downloaded the newest version and started all over again. This time all seems to be working ok. Oh, and yes I was trying to cross-load. Plus one for the tut link! – musoNic80 Oct 04 '10 at 12:24
1

if you have folder structure like:

application/
           modules/
                  users/
                       models/
                             users_m.php

then use this to call modelsin you controller

$this->load->model('users/users_m','',TRUE);
Sam
  • 376
  • 3
  • 10