HMVC: Routing issue |
[eluser]qpixo[/eluser]
I'm using HMVC method but having trouble with routing issue. Does anyone know how to setup a normal site and login part? I can't make the routing work correctly For example, I want to achieve when user is typing http://www.test.com, it will load normal site and http://www.test.com/login, it will load login form Currently, both is located in modules directory
[eluser]weboap[/eluser]
normally with the hmvc you will have Code: /application in module 1 the relation between controllers and the long controller is basically in every controller you test if the user is logged in, if yes run the controller methods if NO redirect to login..... another step to make https://bitbucket.org/wiredesignz/codeig.../wiki/Home work is the routing part it will be as per the example above in config/routes like Code: $route['^(?!module2|module3).*'] = "module1/$0"; hope it help
[eluser]qpixo[/eluser]
[quote author="weboap" date="1337204285"]normally with the hmvc you will have another step to make https://bitbucket.org/wiredesignz/codeig.../wiki/Home work is the routing part it will be as per the example above in config/routes like Code: $route['^(?!module2|module3).*'] = "module1/$0"; hope it help [/quote] Yes this is what I'm using with MX_Controller but I'm having trouble with my route HMVC structure: Code: // Login Login routes file Code: $route['login'] = "login/index"; Site routes file Code: $route['(:any)'] = "site/index"; The problem is: It doesn't recognize http://www.site.com/contact or http://www.site.com/about As error it says: Page request not found
[eluser]InsiteFX[/eluser]
Each module can have its own config and route file!
[eluser]qpixo[/eluser]
[quote author="InsiteFX" date="1337272680"]Each module can have its own config and route file! [/quote] this is what I've done for each...
[eluser]weboap[/eluser]
the modules routes Code: $route['^(?!module2|module3).*'] = "module1/$0"; should be before that the system get to the modules, if you get what mean so that part need to be in the main /config/routes like: Code: [code] Note: i'm here just applying your structure. what i think it should be like is : Code: $route['^(?!login|backend|....).*'] = "site/$0"; Code: $route['login'] = "login/index"; // not needed not needed as in you module local route login been the module and the index your default controller /application/modules/module1/config/routes.php Code: $route['default_controller'] = "index"; doing it this way you can get access to the controllers under site as http://www.site.com/controllers_name controllers under login module or backend module will be http://www.site.com/login/controllers_name http://www.site.com/backend/controllers_name hope it help. note the way you are doing it now to access the contact controller will be like http://www.site.com/site/contact hope it help
[eluser]qpixo[/eluser]
[quote author="weboap" date="1337278574"]the modules routes Code: $route['^(?!module2|module3).*'] = "module1/$0"; should be before that the system get to the modules, if you get what mean so that part need to be in the main /config/routes like: Code: [code] Note: i'm here just applying your structure. what i think it should be like is : Code: $route['^(?!login|backend|....).*'] = "site/$0"; Code: $route['login'] = "login/index"; // not needed not needed as in you module local route login been the module and the index your default controller /application/modules/module1/config/routes.php Code: $route['default_controller'] = "index"; doing it this way you can get access to the controllers under site as http://www.site.com/controllers_name controllers under login module or backend module will be http://www.site.com/login/controllers_name http://www.site.com/backend/controllers_name hope it help. note the way you are doing it now to access the contact controller will be like http://www.site.com/site/contact hope it help [/quote] I'm a bit confused about your example, I have the default application/config/routes.php file and two others routes files in modules directory (application/login/config/routes.php and application/site/config/routes.php) Where on each routes file should I add those lines? My current default application/config/routes.php contains Code: $route['default_controller'] = "site"; What I'd like to do is when user typing: http://www.site.com/login It will load in login form http://www.site.com/ and, or http://www.site.com/contact It will load in public normal site
[eluser]weboap[/eluser]
quick question: is there a reason you are trying to set login as a separate module? not a controller?
[eluser]qpixo[/eluser]
[quote author="weboap" date="1337280916"]quick question: is there a reason you are trying to set login as a separate module? not a controller?[/quote] cause I want to experiment/learn HMVC structure. I think most intermediate and complex websites use it...
[eluser]weboap[/eluser]
in : application/config/routes.php Code: //add in application/modules/login/routes.php Code: //change to in application/modules/site/routes.php Code: //change to in application/modules/backend/routes.php Code: //change to that should do it. |
Welcome Guest, Not a member yet? Register Sign In |