CodeIgniter Forums
Modular Extensions - HMVC version 5.3 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Modular Extensions - HMVC version 5.3 (/showthread.php?tid=33523)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39


Modular Extensions - HMVC version 5.3 - El Forum - 09-19-2010

[eluser]wiredesignz[/eluser]
Use the Modules::locations array in MX / Modules.php


Modular Extensions - HMVC version 5.3 - El Forum - 09-19-2010

[eluser]nfx-nano[/eluser]
Thanks. Another question.

I have this module (dir) structure:

Code:
modules/general/module1
modules/general/module2
modules/etc/module1
modules/etc/module2

How do I show the “general” part in the URL? ie.

Code:
mysite.com/general/module1
mysite.com/general/module2



Modular Extensions - HMVC version 5.3 - El Forum - 09-19-2010

[eluser]wiredesignz[/eluser]
Sub-modules are not supported.
Module controllers in sub-directories is supported.


Modular Extensions - HMVC version 5.3 - El Forum - 09-19-2010

[eluser]seanloving[/eluser]
This is my libraries/MX_Controller.php file for CI 1.7 + HMVC 5.2:
Code:
class Application extends Controller
{
    function Application()
    {
        parent::Controller();
    }

    function login()
    {
        $this->load->library('auth');
        $this->auth->login();
    }

Where does this code go when I "upgrade" to 1.7 + 5.3?


Modular Extensions - HMVC version 5.3 - El Forum - 09-20-2010

[eluser]wiredesignz[/eluser]
Code:
require_once APPPATH.'third_party/MX/Controller.php';

class Application extends MX_Controller
{
    function __construct()
    {
        parent::__construct();
    }

    function login()
    {
        $this->load->library('auth');
        $this->auth->login();
    }

Try that as application/libraries/MY_Controller.php in 1.7.2


Modular Extensions - HMVC version 5.3 - El Forum - 09-20-2010

[eluser]nfx-nano[/eluser]
[quote author="wiredesignz" date="1284937074"]Sub-modules are not supported.
Module controllers in sub-directories is supported.[/quote]
Yeah, I figured something like that was the case. If I add the sub-modules to the locations array however, they work just fine. The only thing that's troubling me is routing the dir-name to the URL.


Modular Extensions - HMVC version 5.3 - El Forum - 09-20-2010

[eluser]Phil Sturgeon[/eluser]
[quote author="nfx-nano" date="1284994280"][quote author="wiredesignz" date="1284937074"]Sub-modules are not supported.
Module controllers in sub-directories is supported.[/quote]
Yeah, I figured something like that was the case. If I add the sub-modules to the locations array however, they work just fine. The only thing that's troubling me is routing the dir-name to the URL.[/quote]

You can create multiple module locations but you won't be able to route the URL to those different locations. Locations are just searched in turn, if the module is not in one it goes to the next. No routing takes place to find them.


Modular Extensions - HMVC version 5.3 - El Forum - 09-20-2010

[eluser]newkiwi[/eluser]
Hi wiredesignz

I note that in http://ellislab.com/forums/viewthread/115465/

You said
Quote:When using Modular Extensions 5.2 the controller and CI are separate objects so the profiler (using CI) will not see a controller class variable unless you specifically pass a reference.

Maybe something like this in your controller constructor

Code:
CI::instance()->data =& $this->data;

I assume this is still the case in 5.3


I hit the same issue in 5.3 + CI2.0 - extended controllers as
MX_Controller -> MY_Controller -> User_controller
with app "global" vars in MY_Controller e.g. $this->data
but cannot access MY_Controller $this->data from User_controller with $this->data or from libraires with $this->ci->data.


Q #1 Is this by design?


Q #2 To work around this I use a "shared" library that I run from User_controller construct to store all global app varies and initialization, [transfered them from MY_Controller]
- this way any extended Controllers like User_Controller and other libraries can access these variables

Is this the way to do it rather than storing global vars in the base (MX and MY) controllers?? ....and the more "theoretically" and "puristically" correct approach??


Modular Extensions - HMVC version 5.3 - El Forum - 09-20-2010

[eluser]bryantAXS[/eluser]
@newkiwi I'm running into the same issue, what does that library your using to create your global vars ($this->data) look like?


Modular Extensions - HMVC version 5.3 - El Forum - 09-20-2010

[eluser]maltzurra[/eluser]
I'm using hooks to determine the language to be used. And I need to enable language.php config file application-wide.

Code:
$autoload['config'] = array('language');

Now, the above code does NOT seem to work on application/config/autoload.php. It WORKS on application/modules/controller/config/autoload.php though.

I'm not interested in doing $this->load->config('language') on my base controller. I prefer loading the way I said.

Is it a bug or should it work this way?