@darkhouse, You could try using a catchall route sending everything to your default controller and use the _remap() method to sort out the URL.
$route['(.*)'] = $route['default_controller'].'$1';This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
January 29, 2011 1:58am
Subscribe [99]#31 / Apr 06, 2011 1:15am
@darkhouse, You could try using a catchall route sending everything to your default controller and use the _remap() method to sort out the URL.
$route['(.*)'] = $route['default_controller'].'$1';#32 / Apr 06, 2011 6:47am
hi `m new to hmvc pattern.. could u guide me how to integrate it with CI2.0
#33 / Apr 06, 2011 7:22am
Did you read the article on HMVC in the WIKI? That explains how to set it up and use it.
InsiteFX
#34 / Apr 06, 2011 7:34am
@InsiteFX,
thnx for ur reply 😊
actually i was converting my application to hmvc. In my application i had a small tweak in MY_router.php . it made me to stumble upon the hmvc installation. now i altered my old my_router.php compatible with HMVC extension. now everything works like charm. Thnx for ur assist 😊
#35 / Apr 06, 2011 9:05am
@wiredesignz: Yeah, I really wanted to stay away from that. I don’t want to have to add manual routing for every controller each time.
I ended up going through the code and adding a quick fix that seems to be working very well. The only issue is that when you have an update, I’ll have to modify the code again. Here’s what I did.
In application/third_party/MX/Modules.php on roughly line 92, in the load method, I changed to
list($class) = CI::$APP->router->locate($segments, true);In application/third_party/MX/Router.php on roughly line 63, the locate method, I changed to
public function locate($segments, $get_module=false) {Then still in that file, on roughly line 79, I changed to
list($module, $directory, $controller) = array_pad($segments, 3, NULL);
if($get_module !== false){
foreach (Modules::$locations as $location => $offset) {And added the corresponding close bracket on roughly line 114, right after the foreach closes.
And finally, in application/core/MY_Router.php on roughly lines 32 and 33 I changed to
public function locate($segments, $get_module=false){
if($located = parent::locate($segments, $get_module)) return $located;And I believe that’s it. The only other thing I’d like to do is make it a config option so that I can turn the feature on an off for different projects, but I’ll worry about that later.
#36 / Apr 20, 2011 5:59pm
Is it possible to extend the lang library? I tried dropping application/libraries/MY_Lang.php with: class MY_Lang extends MX_Lang {... and it did not work. I was following the instructions on the ME site “All MY_ extension libraries should include (require) their equivalent MX library file and extend their equivalent MX_ class”.
Looking through the ME code it looks like it never looks for a MY_Lang file, how can I have it search for this first? Can any MX libraries be extended?
#37 / Apr 20, 2011 6:47pm
drop it in core for ci2.
#38 / Apr 20, 2011 6:51pm
Also, why when I make a controller that is extended from MX_Controller it will auto-load items in my autoload config but when I extend from CI_Controller it will not?
I am refering to just application/config/autoload.php
#39 / Apr 20, 2011 6:52pm
osci,
when I do that I get the error:
Fatal error: Class ‘CI_Controller’ not found in D:\Development\intranet_new\system\core\CodeIgniter.php on line 231
#40 / Apr 21, 2011 3:34am
@wilso417 ,
did u dropped ur MY_lang file inside the “application\core”
#41 / Apr 21, 2011 1:14pm
Yes, I tried MY_Lang.php in application/core which returned the controller error. I also tried it in application/libraries and it just did not pick up. After digging around the HMVC I noticed it was not being checked for at all, so I put in some checks for it. In base.php I did a check to include the file (at the top):
if (file_exists(APPPATH . ‘libraries/MY_Lang.php’)) require_once APPPATH . ‘libraries/MY_Lang.php’;
else require_once dirname(__FILE__).’/Lang.php’;
Next I checked to initialize in the CI constructor:
if (!is_a($this->lang, ‘MY_Lang’) && !is_a($this->lang, ‘MX_Lang’)) $this->lang = (class_exists(‘MY_Lang’, FALSE)) ? new MY_Lang : new MX_Lang;
Not sure if this is the best approach, but this was a workaround I found. I was just surprised something like this was not built in to HMVC since the wiki says you can still extend libraries.
#42 / Apr 21, 2011 1:20pm
whats the version of CI you use???
#43 / Apr 21, 2011 1:35pm
Newest CI & ME HMVC. Just downloaded and set them up a few days ago
#44 / Apr 21, 2011 1:46pm
did you inherited my_lang like this inside core?
require APPPATH.“third_party/MX/Lang.php”;
class MY_Lang extends MX_Lang {}
#45 / Apr 21, 2011 1:52pm
Yes I did. In fact, even with my workaround I still have to do that.