Welcome Guest, Not a member yet? Register   Sign In
Modular Separation - PHP5 (Modules)
#61

[eluser]ed_ball[/eluser]
Hi,

I have just added the MY_Loader and MY_Router files to my existing application/libraries directory (no modules yet), but models are now not being loaded.

Message: Undefined property: Home::$Business_model

Is there something else I need to do on implementation?
I am currently using MY_Controller and the application directory is outside the system directory if this makes any difference.

Thanks,
Ed

EDIT: Seem to have fixed this now. For reference, when accessing methods within a model, the model name needs to be lowercase, e.g. $this->business_model->some_method().
This is inconsistent with the CI user guide, which states:

Quote:Once loaded, you will access your model functions using an object with the same name as your class:

$this->load->model('Model_name');
$this->Model_name->function();
#62

[eluser]ed_ball[/eluser]
Further to my post above, I would suggest that line 132 of MY_Loader is edited to remove the strtolower() function, unless this is performing some other function.

It seems best that the CI conventions are adhered to regarding the uppercase model name here.
#63

[eluser]wiredesignz[/eluser]
@ed_ball, Read the user guide again, the example below the one you mention shows using a lowercase model name. In fact the CI convention is to use lowercase file names for all files except libraries which are uppercase first character.
#64

[eluser]antonumia[/eluser]
I'm just starting working on modularising an app but I'm not sure whether to use ME or MS...

Is there a simple way to decide?

thanks,

anton

Update: duh, hmvc of course :/
#65

[eluser]ed_ball[/eluser]
@wiredesignz, thanks for your response. My issue was that I have not used aliases for any of my models, so all calls to them have been with uppercase first, i.e. $this->Model_name->function().

However, because MY_Loader then gives each model with no alias a default lowercase alias (model_name), I have to rewrite all my code to call $this->model_name otherwise it does not recognise the object. I just wondered if it was actually necessary to create these lowercase aliases, rather than leave them as is (given that both forms are acceptable as per the user guide).

Incidentally, this is independent of the filenames themselves, which are all lowercase.
#66

[eluser]wiredesignz[/eluser]
@ed_ball, The CI convention for variable (or alias) names is also to use all lowercase characters. The uppercase first example in the user guide is NOT correct and it needs updating.
#67

[eluser]ed_ball[/eluser]
Guess I better replace all my uppercase calls with lowercase ones then *sigh*
#68

[eluser]crnalajna[/eluser]
How can I call module/method from _remap() method?
Is it possible?
thanks
#69

[eluser]the_yk[/eluser]
Hi wiredesignz,

I love this modular things, and I've been playing with it for some times now.
It's great coz I don't have to put all my controller in one controllers folder anymore.
So my code can be categorized/modularized Big Grin

But then, I have to create controllers folder inside my modules folder, and put my controller file there (also for models and others).
It makes my modules folder having so many subfolders inside it, although there are only one or two files inside each subfolders.
(well, not a big issue though :p )

It would be great if I can use an alternative way to put my controller file.

Rather than
modules/mymodule/controllers/mycontroller.php
modules/mymodule/controllers/anothercontroller.php
modules/mymodule/models/mymodel_model.php
I can use an alternative way
modules/mymodule/controller.mycontroller.php
modules/mymodule/controller.anothercontroller.php
modules/mymodule/model.mymodel_model.php

I think it may come in handy Smile

Let me hear your thought.

my regards,
~yk~
#70

[eluser]AgentPhoenix[/eluser]
I'm just curious why though. What you're suggesting flies in the face of the CodeIgniter convention.




Theme © iAndrew 2016 - Forum software by © MyBB