Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - HMVC version 5.4

[eluser]Unknown[/eluser]
There appears to be a bug in the HMVC loader class when loading a library using an alias. I need two different instances of a library on the same page.

For instance,

$this->load->library('template', NULL, 'instance_1');

$this->load->library('template', NULL, 'instance_2');

But I always get back instance_1.

The problem appears to be in the MX/Loader method library(). Once the first load of the library class get cached, it always returns and doesn't allow the alias logic for the second call to execute

public function library($library = '', $params = NULL, $object_name = NULL) {

if (isset($this->_ci_classes[$class]) AND $_alias = $this->_ci_classes[$class])
return CI::$APP->$_alias;

}

Am I missing something?

thx



[eluser]Keat Liang[/eluser]
the latest changes in CI develop, the config/autoload.php

add a new "driver" category, HMVC does not support it yet

details:
https://github.com/EllisLab/CodeIgniter/...c05f50dc12
https://github.com/EllisLab/CodeIgniter/...48888a16ee
https://github.com/EllisLab/CodeIgniter/...471664163b
https://github.com/EllisLab/CodeIgniter/...39c7c080f7

hope we will get some update soon.

[eluser]ZaLiTHkA[/eluser]
I've been playing around with HMVC for a little while now, but I'm trying to do something now that's pushing rather hard on the boundaries of my PHP knowledge.. So, here's me hoping someone here could help point me in the right direction or give me a few tips. Smile

For the moment all I'm looking at is the loading of views. Currently, this HMVC extension checks for the requested view in the 'application/[current_module]/views' first, then the default 'application/views' folder if the first is false. In my little pet project, I would like to insert my own 'view' folder location check just before the HMVC one.

Working with the following folder structure:
Code:
/* -------------------------------------
- application
  - modules
    - module_a
      - controllers
        - module_a.php
    - module_b
      - controllers
        - module_b.php
      - views
        - module_b.php
    - module_c
      - views
        - module_a.php
        - module_c.php
------------------------------------- */

If I do something like this:
Code:
class Module_a extends MX_Controller {
    public function index() {
        $this->load->view('module_a');
    }
}

I would like to check the 'module_c' views folder first for a match, then the current module (module_a) if the first check is false. Just to add another interesting twist, I've already completely removed the default 'application/views' folder, since it's not going to be used for this project. Smile

Would I need to edit the 'public function view()' function in 'third_party/MX/Loader.php', or could I perhaps do this outside of that file?

[eluser]XMadMax[/eluser]
Thanks wiredesignz, HMVC absolutely essential for my developments.

I have made a mix between CI 2.1.2, HMVC 5.4 and a common application folder.

Inside the common application folder are the HMVC, leaving the normal application folder untouched.

Also, with common folder, you can have modules, libraries, helpers, third_party, shared between many application folders.

This is a basic approach to those who need a general application (modules, controllers, views, libraries, helpers, language, etc, but only a small customization is needed for different purposes.

Then, you have a 'common' folder, also a 'application1' folder, 'application2' folder and so on...

Take a look at: https://bitbucket.org/xperez/codeigniter...ions-xhmvc

[eluser]goFrendiAsgard[/eluser]
Hi everyone, I have a problem related to using get_instance after extend my controller from MX_Controller.
I write everything here: http://ellislab.com/forums/viewthread/224908/

Hopefully someone can help me.
Thanks

[eluser]ilumos[/eluser]
Hello all,

I'm having trouble getting my head around how to do view partials right, without repeating lots of code.

http://ellislab.com/forums/viewthread/224791/

In hindsight, I should've posted my problem in here, rather than the code forum.

Any help appreciated.

Thanks!

[eluser]nsyed[/eluser]
Found a bug in HMVC's Loader that leads to a "Fatal error: Maximum function nesting level of '100' reached, aborting!"

The error can be reproduced by creating an autoload config file within a module and adding a library to load. Ex:
Code:
modules/
..admin/
....config/
......autoload.php
....libraries/
......admin_controller.php

The problem was that the '_autoloader' function kept recursively trying to "autoload" the library regardless of whether or not it's already loaded. This lead to an endless loop where the loaded file (which extends the MX_Controller) called it's parent controller which in turn tried to 'initialize' on every call in which '_autoloader' was called again and again (a recursive result of the infamous 'goto').

I solved this by adding a line in the Loader to check if the class was already loaded so it doesn't recurse itself...

Code:
// MX/Loader.php
// line (396-398)?:
// -> replace:
// foreach ($autoload['libraries'] as $library) {
//     $this->library($library);
// }
// -> to:
foreach ($autoload['libraries'] as $library) {
    if (class_exists($library, FALSE)) continue;
    $this->library($library);
}


~NS

[eluser]wiredesignz[/eluser]
The problem occurs because you have incorrectly put a controller into the libraries directory.
I don't agree that altering any code is required because the library loader already checks for the class so you're just duplicating code to fix your mistake.

[eluser]nsyed[/eluser]
[quote author="wiredesignz" date="1349332703"]The problem occurs because you have incorrectly put a controller into the libraries directory.
I don't agree that altering any code is required because the library loader already checks for the class so you're just duplicating code to fix your mistake.[/quote]

Do the modules support extending the core class? or look for the extensions in a special folder where I can place my custom classes to extend the core through a module? Duplicating code to fix my mistake..? I'm sorry, didn't know you would be offended by a simple solution that makes it easier to extend core..

I know you can add a separate function in HMVC to look into a "core" folder within the module and extend core classes from thereon but I'm a bit lazy so that was sufficient lol.

[eluser]wiredesignz[/eluser]
I'm not offended at all. Just stating a fact.

CI conventions indicate that controllers and their ancestors provide core functionality they are not defined as libraries.

If you need a base controller you can create a core directory in your module and include the parent class as per your normal PHP directives or place them into the application/core directory to be autoloaded.

Also if you load a base controller as a library then you are instantiating a redundant controller instance which seems pointless.

In future it might be worth looking at the Modules::autoload() method to accommodate loading core files from modules too.




Theme © iAndrew 2016 - Forum software by © MyBB