![]() |
** solved ** dynamic routing from database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: ** solved ** dynamic routing from database (/showthread.php?tid=24716) Pages:
1
2
|
** solved ** dynamic routing from database - El Forum - 11-17-2009 [eluser]Tottys Design[/eluser] Can a hook load a controller? ** solved ** dynamic routing from database - El Forum - 11-17-2009 [eluser]davidbehler[/eluser] Without thinking too much about it I would say no. The controller that will be loaded is defined by the url/the routing defined in config/routes.php The "pre_system" or the "pre_controller" controllers could be used to redirect to another url I guess...maybe even hack the routing? Don't know...just a wild guess here. Why would you need that anyway? ** solved ** dynamic routing from database - El Forum - 11-17-2009 [eluser]Tottys Design[/eluser] [quote author="waldmeister" date="1258508147"]Without thinking too much about it I would say no. The controller that will be loaded is defined by the url/the routing defined in config/routes.php The "pre_system" or the "pre_controller" controllers could be used to redirect to another url I guess...maybe even hack the routing? Don't know...just a wild guess here. Why would you need that anyway?[/quote] I need to make a dynamic multilanguage website, take a look at the urls: en/gallery/ pt/galeria/ it/galeria/ both should trigger the gallery controller. 1) the params are stored, 2) then converted in the main language (gallery to gallery, and galeria to gallery) 3) load the controller named gallery ** solved ** dynamic routing from database - El Forum - 11-17-2009 [eluser]Colin Williams[/eluser] Let us know exactly what you are trying to achieve and we might be able to offer a good solution that fits with CI's philosophy and conventions. ** solved ** dynamic routing from database - El Forum - 11-17-2009 [eluser]Tottys Design[/eluser] [quote author="Colin Williams" date="1258509415"]Let us know exactly what you are trying to achieve and we might be able to offer a good solution that fits with CI's philosophy and conventions.[/quote] I need to make a dynamic multilanguage website, take a look at the urls: en/gallery/ pt/galeria/ it/galeria/ both should trigger the gallery controller. 1) the params are stored, 2) then converted in the main language (gallery to gallery, and galeria to gallery) 3) load the controller named gallery ** solved ** dynamic routing from database - El Forum - 11-17-2009 [eluser]Colin Williams[/eluser] Sorry about that. I posted mine before seeing your response. You could achieve 2 and 3 with simple routing rules: Code: $route['([a-z]{2})/gal([^\/]*)'] = "gallery/$1"; Then take care of #1 in the gallery controller constructor, where $this->uri->segment(1) is the language code. ** solved ** dynamic routing from database - El Forum - 11-17-2009 [eluser]Tottys Design[/eluser] [quote author="Colin Williams" date="1258509759"]Sorry about that. I posted mine before seeing your response. You could achieve 2 and 3 with simple routing rules: Code: $route['([a-z]{2})/gal([^\/]*)'] = "gallery/$1"; Then take care of #1 in the gallery controller constructor, where $this->uri->segment(1) is the language code.[/quote] No problem. I know but I don't want to work with routers because I can add new categories and then I should make them available in different languages, and i have to mod always the route file. Look at the code I have to use to get the controller name, then this should dispatch the action to that controller, but how?-I really don't know. Here I share my code: (in the next post) ** solved ** dynamic routing from database - El Forum - 11-17-2009 [eluser]Tottys Design[/eluser] Code: <?php ** solved ** dynamic routing from database - El Forum - 11-17-2009 [eluser]Tottys Design[/eluser] Code: } ** solved ** dynamic routing from database - El Forum - 11-17-2009 [eluser]Colin Williams[/eluser] Advanced routing usually involves overloading the core Router class (creating a MY_Router library). If you take a look at the Router class, it should be pretty clear where you'll want to make your modifications. |