Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - (HMVC) - Version 3.1.9

Current Version is 3.1.0
Modular Extensions is now two files:


A few nice features are worth mentioning:

Controllers, Models and of course Modules can load files from any other module directory.
//loading a HMVC Module into a Controller, two options.
$this->menu =& modules::load('admin/menu');    //loads menu.php from modules/admin/controllers
modules::load(array('admin/menu' => $page));   //same result passing values to the module

//loading a Model from a module directory
$this->users =& modules::load('admin/users_model', 'models/'); //specify the directory to load from
modules::load(array('admin/users_model' => $user), 'models/'); //same result as above passing values

//attach a module to a core class (assume CI_Validation is loaded)
$this->validation->setup =& modules:load('admin/validation_setup');  //attach and setup fields/rules

Same process for Views and Libraries, just specify the module directory and sub-directory as above.

A file is available for download: http://codeigniter.com/wiki/File:modular...s_310.zip/

Feedback is appreciated. Thank you for your interest. Wink

Current Version is 3.1.2

The Modular Extension directories can now be organised with proper structure.
Config, Controllers Libraries, Models, Views, Helpers and Plugins are supported.

A file is available for download: http://codeigniter.com/wiki/File:modular...s_312.zip/

Feedback is appreciated. Thank you for your interest Wink

Current Version is 3.1.3

Available on the wiki: http://codeigniter.com/wiki/Modular_Extensions_-_HMVC/

A file is available for download: http://codeigniter.com/wiki/File:modular...s_313.zip/

Feedback is appreciated. Wink

[eluser]Edemilson Lima[/eluser]
I have a view that runs a module:
<div class="publish">&lt;?=modules::run('adsense',NULL,'button')?&gt;</div>
<div class="publish">&lt;?=modules::run('adsense',NULL,'skyscraper')?&gt;</div>
The module is:
// application/modules/adsense.php:
class Adsense extends Module {

    function Adsense() {
    function button() { // 125x125 pixels
    function vertical() { // 120 x 240 pixels
    function skyscraper() { // 120x600 pixels
    function rectangle() { // 300x250 pixels
    function leaderboard() { // 728x90 pixels

But it is producing the error:
Unable to load the requested module:
Doesn't it have anymore the option to load a module right from the modules directory?

Yes that still is a feature.

The error indicates it can't find your adsense module in the path its searching.

check it's location and filename. application/modules/adsense/controllers/adsense.php

[eluser]Edemilson Lima[/eluser]
application/modules/adsense/controllers/adsense.php ?

I did place it at:


If I want my modules to load the views, models, libraries, helpers and plugins from their original directories, can't be the modules directory used like any other directory in CI? I was thinking I could put my modules on it, and even create more custom folders into the modules directory, to organize my modules. CI works with the application directories as repositories, where it loads the files. Shouldn't the modules directory work this way too? Smile

The modules are HMVC applications with their own controllers, models, views etc.

Calling a module controller such as Adsense.php is a call to a HMVC controller, just like CI calls its own controllers. You pass controller name, data, and method.

You can use original CI models, libraries and views from modules by using `$this->load->` method as normal.

If you want to a module use its own resources or resources of other modules you use the `$this->load->module->` method.

Hope this helps. Wink

[eluser]Edemilson Lima[/eluser]
Hmmmm... I see. I already knew that it have a support for a full HMVC, but I did think it will keep the original idea of using modules as partials, without they need to have such MVC structure.

Is not possible to change the actual version to use modules this way too?

Yes, if you modify modules_helper.php it will not use the controllers directory unless you specify.

function & load($modules, $dir = 'controllers/')  //remove `controllers/`

function & load($modules, $dir = '')

[eluser]Edemilson Lima[/eluser]
What about if it check if the module exists in the path "application/modules/$module.php", and if it was not found there, then it try to load from the "application/modules/$module/controllers/$module.php"? By this way will be better to use Modular Extensions only for rendering partials. I think many people will use it only for this purpose.

Then the module in "application/modules/$module.php" will load views, models, libraries, helpers and plugins only from the original CI folders. Is this possible?

Theme © iAndrew 2016 - Forum software by © MyBB