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) |
Modular Extensions - HMVC version 5.3 - El Forum - 11-03-2010 [eluser]wilso417[/eluser] Hey guys, Adding a config/routes.php inside a module folder does not work as expected. I assumed adding specific routes inside a module would behave exactly like if I was tacking those on at the end of app/config/routes.php. However, this does not work as expected... it seems like config/routes.php is then used just to send to the module and will not follow the whole routing is matched. Instead it behaves like config/routes.php just gets the module, then the module specific routes does the rest. Is this correct? Modular Extensions - HMVC version 5.3 - El Forum - 11-03-2010 [eluser]wilso417[/eluser] For instance: app/config/routes.php: $route['admin/([a-zA-Z_-]+)/(:any)'] = "$1/admin/$2"; modules/news/config/routes.php: $route['news/:any'] = "news/views/$1"; any url like: admin/news/function will reroute to news/views/function instead of news/admin/function. Now if I put the module specific routes inside the app routes, it will reroute as expected. Modular Extensions - HMVC version 5.3 - El Forum - 11-03-2010 [eluser]wiredesignz[/eluser] The module name is not needed in the route value. It is assumed. Code: $route['news(.*)'] = 'views$1'; This segments will be a controller/method or sub-directory/controller/method etc Modular Extensions - HMVC version 5.3 - El Forum - 11-03-2010 [eluser]iloveci[/eluser] I've just recently downloaded this and started playing around with it after seeing it put to good use in pyrocms. I just wanted to thank you for sharing it wiredesignz. Modular Extensions - HMVC version 5.3 - El Forum - 11-04-2010 [eluser]wiredesignz[/eluser] @iloveci, You're welcome, thanks. Modular Extensions - HMVC version 5.3 - El Forum - 11-05-2010 [eluser]loosetops[/eluser] Hi Wired modules::run is not working. No error given, just returns nothing. I this kind of set up Code: class MY_Controller extends MX_Controller In the content_creator module I try to run a method in the thesaurus controller Code: $this->data['thesaurus_widget'] = modules::run('thesaurus/widget'); Now thesaurus/widget routes to thesaurus/home/widget and there is modules/thesaurus/view/widget_view.php I can access the widget fine from the url, but both cross loading techniques return nothing. No error. In fact modules::run doesn't even call the controller method(I put an exit; in there to test). load->view complains if I give it a non-existent view file but modules::run does not. All this is on localhost Thanks Modular Extensions - HMVC version 5.3 - El Forum - 11-05-2010 [eluser]wiredesignz[/eluser] Is there a reason that you need to use modules::run via the routing instead of directly? Code: modules::run('thesaurus/home/widget'); You may not see anything from modules::run while testing because output is buffered. Modular Extensions - HMVC version 5.3 - El Forum - 11-05-2010 [eluser]loosetops[/eluser] [quote author="wiredesignz" date="1288972377"]Is there a reason that you need to use modules::run via the routing instead of directly? Code: modules::run('thesaurus/home/widget'); You may not see anything from modules::run while testing because output is buffered.[/quote] I have tried both to same effect. Is there a way to tell if the output is buffered? I kinda doubt that is happening as I have tried echoing whatever is returned. And an exit; in the controller function being called by run() doesn't event halt the program. Edit: I might have found a bug. I realized my error logging wasn't on turning it on shows the errors Code: modules::run('thesaurus/home/widget'); For some reason the run method adds a 2nd controller class. Given module/controller/method it tries to run module/controller/controller/method I have no clue why it is doing that. Modular Extensions - HMVC version 5.3 - El Forum - 11-05-2010 [eluser]loosetops[/eluser] third_party / MX / Modules.php is faulty Code: 52 public static function run($module) { Given Code: modules::run('module/controller/method'); An echo at line 63 Code: echo $module,'<br />',$controller,'<br />',$method,'<br />'; As a result the ifs at lines 64 or 66 fail. The self::load at 64 may be loading the wrong controller leading to a fail at 66. Modular Extensions - HMVC version 5.3 - El Forum - 11-05-2010 [eluser]wilso417[/eluser] [quote author="wiredesignz" date="1288837291"]The module name is not needed in the route value. It is assumed. Code: $route['news(.*)'] = 'views$1'; This segments will be a controller/method or sub-directory/controller/method etc[/quote] I tried that with this: app/config/routes.php: $route[‘admin/([a-zA-Z_-]+)/(:any)’] = “$1/admin/$2”; modules/news/config/routes.php: $route[‘news/:any’] = “views/$1”; still does not work with a url of admin/news/function. It redirects to news module only, and then modules/news/config/routes.php tries to redirect and goes to 404. If I do: app/config/routes.php: $route['admin/([a-zA-Z_-]+)/(:any)'] = "$1/admin/$2"; $route['news/(:any)'] = "news/view/$1"; That will work. That is how i'd expect putting routes in my module folder, that it'd be a lower precedence but that is not the case. What is the point of putting routes inside a module then? |