Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - Version 4.3

[eluser]wiredesignz[/eluser]
@Mikey, CI will not allow you to load both your base class and its MY_ extension from the application/libraries directory so ME is not different here.

If there is any limitation it is certainly not with the Template library or with Modular Extensions.

[eluser]bEz[/eluser]
[quote author="wiredesignz" date="1204603833"]This marks the release of Version 4 of Modular Extensions - HMVC. (4th re-write)
Modular Extensions HMVC enables you to use self contained HMVC modules that can be accessed by Controllers, Models and Views.
The scripts have been wriiten to be smaller, faster and to provide cascading file searching.
$this->load->xxx() can be used withn modules just as within normal controllers.
Version 4 is described on the wiki. Modular Extensions - HMVC
Any feedback would be appreciated. Thanks for your interest.[/quote]

Which is the more stable/tested version to use v5.x or v4.x?
I'm aware that v5.x is php5 only!

I am currently using v5.2. On my local dev server (xampp), I can load the base url and get to the welcome page, however after uploading to a unix server and updating necessary configs, I get:
"Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid."


CI v1.7.1
- App on a sub-folder
- .htaccess
- sys and app are outside of the public_html realm.
- I have another CI system/application that still works on the server (separate folder).

[eluser]bEz[/eluser]
Through my search, I have been unsuccessful to isolate the error message:
Quote:“Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.”

The few search results on ME + error message had the replies stating that the issue had been resolved/fixed.

This problem only occurs on a production server.
My local (xampp) server runs ME v5.2 flawlessly.
The error fails on:
Quote:domain
domain/module
domain/module/controller
domain/module/controller/class
domain/module/controller/class/method
domain/module/controller/class/method/var1
domain/module/controller/class/method/var1/...

[eluser]bEz[/eluser]
The problem with the above error message was the result of not having a controllers folder in the base application folder.

Undecided jeez, can't believe this hasn't been caught before.

[eluser]Mikey McCorry[/eluser]
[quote author="wiredesignz" date="1238177965"]@Mikey, CI will not allow you to load both your base class and its MY_ extension from the application/libraries directory so ME is not different here.

If there is any limitation it is certainly not with the Template library or with Modular Extensions.[/quote]

Just tested, and you are absolutely correct. It seems that Matchbox allows this behavior, which is what threw me off. I've come up with a work-around (extending the library under a different name instead of a MY_ prefix - it's less elegant, but actually works better for my requirements). Now to see if my app will work with ME instead of Matchbox. Fingers crossed. Smile Thanks again for your help. Much appreciated.

[eluser]Mikey McCorry[/eluser]
Hi! Me again Smile

I've been implementing ME-HMVC into my app and after a few hurdles, it seems to be going okay so far, however I've got a few questions you might be able to help me with.

1. Is it possible to load a module/model (and use it's methods) from inside of another module/model?

In case that needs an example: Say I have a module called 'gallery' which has two models 'gallery_images' and 'gallery_categories'. I have a method in 'gallery_categories' called display($cat_id) which displays each image in a particular category using $this->gallery_images->thumbnail($image_id). I don't seem to be able to use $this->load->model('gallery_images') from inside the gallery_categories model. I've been looking through this thread and found how to do it with ME 4.0.30

(I know this isn't the best way to do it. I'm not doing exactly this, this is just an example of functionality I need.)

2. Likewise, is it possible to load a module/model's method from within a helper? I've been reading back through this thread and I get the impression this (and my previous question) was possible in earlier versions of ME-HMVC.

3. An earlier version of ME-HMVC had a downloadable example app that had models and helpers loaded from all over the place. This looked good, but then realized it wasn't going to help me with this latest version. Any plans to update this example?

4. Is there a way to autoload a model that's inside a module? I read something about hooks, but the user guide and forums were a little light on info about how these are implemented, especially with regard to loading models/helpers/libraried from modules with ME-HMVC. Basically I have a 'users' module and model that I'd like to be able to access from anywhere (to check if users are logged in, etc.) This works okay when it's not in a module (ie. just in the apppath), but I'd like to modularize this if possible.

Sorry for asking so many questions. Cheers and thanks again for the help.

[eluser]wiredesignz[/eluser]
Hi Mikey,

Module autoloading is easy to achieve.
Modules may have a `module-name`/config/autoload.php file formatted the same as your application/config/autoload.php file

Modules may also have an $autoload class variable.
Code:
var $autoload = array(
        'model' => array('page_article_model','content_model'),
        'helper' => array('url','form','asset','il8n')
        );

Loading resources from other modules was an option until CI had sub-directory structure added (1.7.0).
Cross loading files has since been dropped in favour of using sub-directories to remain compatible with CI.

You may use modules::run() to get your data from a designated controller method that in turn loads your models and runs the query for you.

Good luck

[eluser]Mikey McCorry[/eluser]
Great! That gives me heaps to go on with.

With regard to autoloading, I was really hoping I'd be able to autoload a module's model (eg. the user module's model) and have it available globally, ie. be able to call:
Code:
if ($this->user_model->is_logged_in()) {
   ...
}
but if I'm correct in understanding you, I should be able to just make a method in my users controller and use:
Code:
// if I'm in a model, helper, view, etc.
if (modules::run('users/is_logged_in')) {
   ...
}
// or if I'm in another controller...
$this->load->module('users');
if ($this->users->is_logged_in()) {
   ...
}
Does this look right?

Finally, about sending method arguments to the modules::run() function? Are they just included in the first argument:
Code:
$user_mikey = modules::run('users/get_user/mikey') // mikey is the parameter passed to get_user()
or are they additional args for the run function:
Code:
$user_mikey = modules::run('users/get_user', 'mikey') // mikey is the parameter passed to get_user()

I'm getting somewhere. This is exciting.

[eluser]wiredesignz[/eluser]
Modular Extensions version 4.3.05 is available on the wiki.

Updated to ME 5.2 functionality

[eluser]Mikey McCorry[/eluser]
Just quickly, for those of us using ME 4, is this a simple drop-in replacement upgrade, or will it require code changes? I'm not too sure of the syntax/functionality differences between ME 4 and ME 5. (I actually thought they were mostly the same apart from speed improvements for the PHP5 version.) Is there a benefit to upgrading?




Theme © iAndrew 2016 - Forum software by © MyBB