CodeIgniter Forums
Modular Extensions - HMVC version 5.4 - 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.4 (/showthread.php?tid=38057)

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


Modular Extensions - HMVC version 5.4 - El Forum - 10-04-2012

[eluser]nsyed[/eluser]
[quote author="wiredesignz" date="1349337317"]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.[/quote]
Alright awesome then =). I'm new to CI so correct me if I'm wrong. Btw, HMVC is a great addition to CI, I really do like it but of course, stuff needs to be modified when scaling out applications.

Including the parent class as per normal PHP directives defeats the purpose of having the class loaded through the CI system, I'd need to include the class into every controller I make within the module - this is why I wanted to have the class autoloaded since it will be used regardless for all controllers in the module. And placing my extended core classes into core defeats the purpose of individual modularity - and plus, I have other extensions of core classes using the "subclass_prefix."

The Modules::autoload() function does not go to the depth of /module/module_name/core, but rather stays at application level. I'd need to modify this if I wanted this to look for a core folder within a module.

Just because a core class is placed in a "libraries" folder doesn't mean that it has to act like a library. Would I rather put it in a folder called "core" for the sake of indicating it is a core class? Yes, I would love to lol.


Modular Extensions - HMVC version 5.4 - El Forum - 10-11-2012

[eluser]becky.resler[/eluser]
I have a question about routing with modules. I have a setup similar to the following:

Code:
/application/
|--- modules/
   |--- somemodule/
      |--- config/
         |--- routes.php
      |--- controllers/
         |--- admin.php
         |--- foobar.php
         |--- somemodule.php
      |--- models/
      |--- views/

And inside my routes.php file in the module, I have something similar to the following:
Code:
$route['somemodule']        = 'somemodule';
$route['somemodule/foobar'] = 'foobar';
$route['admin/somemodule']  = 'admin';

The first 2 routes work just fine, but the admin route does not.

Based on the searching/research I've done, the Modular Extension script is not made to handle routes (in a routes file within the module) with a path that starts with something other than the module name out-of-the-box. I know that I can put the routes in the main routes file, but I'd like to keep them with the module if at all possible.

Has anyone been able to find a solution to get routes like the 3rd one above to work when put in a module routes file?


Modular Extensions - HMVC version 5.4 - El Forum - 10-31-2012

[eluser]ZaLiTHkA[/eluser]
Hey wiredesignz, I have a question.. Suppose you might think it a strange request, especially considering that HMVC is designed to check for a module first, followed by the default location if no module is found.

Is it possible to prevent any views loading from the default 'views' folder? For example, using this controller:
Code:
class Display extends MX_Controller {
public function index() {
  $this->load->view('display');
}
}

By default, this will look first for 'application\modules\display\views\display.php', then if that fails it will look for 'application\views\display.php'. I want it to only check the modules path for the view and fail if it doesn't exist.. Is this possible?


For some reason, while under Windows CI with HMVC runs fine when I remove the default views folder, when I run the same app on Linux it tells me it can't find the controller. When I create the views folder again (even leaving it empty), the error goes away.

I also tried commenting out the middle section of HMVC's view() method, like this:
Code:
/** Load a module view **/
public function view($view, $vars = array(), $return = FALSE) {
list($path, $_view) = Modules::find($view, $this->_module, 'views/');

// if ($path != FALSE) {
//  $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
//  $view = $_view;
// }
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
}

Thinking that it would try load the module's view and not the default, but even with the view in the 'module\views' folder, I get an error saying it can't load 'display.php'.

Any ideas...?


Modular Extensions - HMVC version 5.4 - El Forum - 10-31-2012

[eluser]GamBeaT[/eluser]
Hey,

I've wanted to download HMVC, but in the "downloads" it says there is nothing to download. do I have to open everything in source and just copy paste the code ? :O


Modular Extensions - HMVC version 5.4 - El Forum - 10-31-2012

[eluser]wiredesignz[/eluser]
[quote author="ZaLiTHkA" date="1351722810"]Hey wiredesignz, I have a question..

...Is it possible to prevent any views loading from the default 'views' folder? ...

Any ideas...?[/quote]

Alter the MY_Loader.php file and add a modified view method.

Check after the modules::find() method that $this->_module value is valid and that the $path value is false. This will indicate that the view does not exist in the module.


Modular Extensions - HMVC version 5.4 - El Forum - 10-31-2012

[eluser]wiredesignz[/eluser]
[quote author="GamBeaT" date="1351747825"]Hey,

I've wanted to download HMVC, but in the “downloads” it says there is nothing to download...[/quote]

Go back to Bitbucket and look more thoroughly.


Modular Extensions - HMVC version 5.4 - El Forum - 10-31-2012

[eluser]ZaLiTHkA[/eluser]
[quote author="GamBeaT" date="1351747825"]Hey,

I've wanted to download HMVC, but in the "downloads" it says there is nothing to download. do I have to open everything in source and just copy paste the code ? :O[/quote]
That confused me a bit when I first found this as well... On the 'Downloads' page, then select the 'Branches' tab and you'll see links on the right hand side.

[quote author="wiredesignz" date="1351749568"]Alter the MY_Loader.php file and add a modified view method.

Check after the modules::find() method that $this->_module value is valid and that the $path value is false. This will indicate that the view does not exist in the module.[/quote]
Ok cool, thanks.. I'll try that when I get home tonight and see what I can do, not actually sure if what I'm trying to do will actually work anyway, but there's only one way to find out. Smile I think I'll base it on an optional extra parameter so I don't end up breaking something else in the process.


Modular Extensions - HMVC version 5.4 - El Forum - 11-01-2012

[eluser]GamBeaT[/eluser]
thanks, got it Smile now got a question, how does this feature works with URI language indentifier ?


Modular Extensions - HMVC version 5.4 - El Forum - 11-01-2012

[eluser]samitrimal[/eluser]
I just downloaded codeigniter 2.1.3 and Hmvc 5.4 , I found that the controllers method is running two times. here below is the code for
Code:
<?php
class Index extends MX_Controller
{
    function index()
    {
      //  $this->load->view('index/index');
       echo "samit<br>";
    }
}
?&gt;
And i Got the result
samit
samit

I think this is a bug.




Modular Extensions - HMVC version 5.4 - El Forum - 11-01-2012

[eluser]wiredesignz[/eluser]
@samitrimal, Be sure to post back when you discover that it's not a bug.