Welcome Guest, Not a member yet? Register   Sign In
Modular Seperation Library Question/Confusion
#1

[eluser]Mischievous[/eluser]
I'm having very odd problems with Modular Separation.

When loading models in sub modules or base models you can't do it on a load of model you have to call it in the function? Anybody have a fix for this?


Ex: I have module "cart" with a controller "cart" that has a model "cart_model" I have to call to the "product_model" inside the "product" module.

To do so i have to load this model in the function and it only sometimes works there?

Also, it absolutely will not load any base models inside of my application folder?


Any work around(s) or solutions would be much much appreciated!


Also, getting this error out of nowhere? was working correctly before?
Quote:Call to a member function _assign_libraries() on a non-object in ..\application\libraries\MY_Loader.php on line 197
#2

[eluser]danmontgomery[/eluser]
[quote author="Mischievous" date="1271897357"]When loading models in sub modules or base models you can't do it on a load of model you have to call it in the function? Anybody have a fix for this?[/quote]

I must say that I don't understand your question at all, but models from another module are loaded as following:

Code:
$this->load->model('module_name/model_name');

Models in ./application/models are loaded normally:

Code:
$this->load->model('model_name');

It looks like you've made some changes to MY_Loader.php? The call to _assign_libraries() isn't on line 197 in either 1.12 (for CI 1.7.x, line 203) or 2.01 (for CI 2.0, line 205)...
#3

[eluser]Mischievous[/eluser]
Yes i had to make some adjustments for my template library that im running because I've placed the templates folder inside of the root directory instead of inside the applications directory because McAfee was hitting me for giving out critical system directories or what not.

I know that too call models inside of other modules you have to specify the module name. But when i try to load models from by base application they dont like loading and I have to autoload them?
#4

[eluser]Phil Sturgeon[/eluser]
I don't understand either.

"I know that too call models inside of other modules you have to specify the module name. But when i try to load models from by base application they dont like loading and I have to autoload them? "

Calling a model, helper, method, etc from anywhere other than inside the module itself needs the module name to be referenced.
#5

[eluser]Mischievous[/eluser]
Ok, so I'll try to setup a scenario with this?


Module Name: "cart"
-Model Name: "cart_model"
-File: ../application/modules/cart/models/cart_model.php

--------------------------
Module Name: "product"
-Model Name: "product_model"
-File: ../application/modules/product/models/product_model.php


When trying to make a call to load the product model inside of the cart model inside of the constructor function

Code:
function
Cart_model()
{
parent::Model();
$this->session_id = $this->session->userdata('session_id');
$this->cart_id = $this->session->userdata('mw_cart_id');
$this->load->model('product/product_model','product');
}

It throws an error that it can't find the model, yet if i load it inside another function say:

Code:
function get_cart()
{
$this->load->model('product/product_model', 'product');
$this->product->fetch(array('sku'=> $sku));
}

This works...

Also loading base application models within a module doesn't work. But if I autoload these or call them from application/controller it will load.

ex:
--------------------------
-Model Name: "array_model"
-File: ../application/models/array_model.php

Loaded from
--------------------------
Module Name: "product"
-Controller_file: ../application/modules/product/controllers/product.php
-Model_file: ../application/modules/product/models/product_model.php
--------------------------
does NOT work...

Loaded from
--------------------------
-Controller_file: ../application/controllers/product.php
-Model_file: ../application/models/product_model.php
--------------------------
DOES work...

Hope this is a better explanation?




Theme © iAndrew 2016 - Forum software by © MyBB