![]() |
Changing URI segments in Code Ingniter - 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: Changing URI segments in Code Ingniter (/showthread.php?tid=18547) |
Changing URI segments in Code Ingniter - El Forum - 05-10-2009 [eluser]MianUsman[/eluser] Hi , i m using codeigniter for one and half year but now i got one situation that i never face and bit confuse about this u all are requested to help me out . i m makeing a multilingual site and i need to have language code at first segment to uri then after this code there will be controller name , function and params to function . e.g. www.abc.com/home here home is my controller but i need www.abc.com/de/home same controller Home should be called as in above URL , may i do this in codeigniter if yes then how i could.please help me out . thanks in Advance Regards Usman Abdul-Razzaq Changing URI segments in Code Ingniter - El Forum - 05-10-2009 [eluser]Dam1an[/eluser] Have you tried using URI routing? Changing URI segments in Code Ingniter - El Forum - 05-10-2009 [eluser]MianUsman[/eluser] Hi, thanks for reply. yeah i have tried the routs file but didn't succeed. really unable to write this kind of code . also i think u didn't understand my requirement www.abc.com/home here home is my controller but i need www.abc.com/de/home means that i don't want to codigniter to assume 'de' as a class OR as a folder in controller folder. also this runs same home controller as upper url is running. its just a language code in which language user is view site. thanks in advance regards Usman Abdul-Razzaq Changing URI segments in Code Ingniter - El Forum - 05-10-2009 [eluser]slowgary[/eluser] URI routing should let you turn: Code: www.abc.com/de/home Code: www.abc.com/home/de This way, you'd still be accessing your controller, and in the controller you can check the uri segment to select the language pack. Right? Changing URI segments in Code Ingniter - El Forum - 05-10-2009 [eluser]Dam1an[/eluser] You're going to need to use routes, extend the router class, or use a pre system/pre controller hook to set the language, and shift the URIs one to the left Changing URI segments in Code Ingniter - El Forum - 05-10-2009 [eluser]tomcode[/eluser] In my latest site I used a customized Router class based on this Wiki entry, I put the changed Router.php into the application library folder. Before I used a central MY_Controller with a Controller foreach language, which would set the language and then use the methods of MY_Controller, suitable for small sites, very readable and fast. Another method using routes is described in the Wiki by wiredesignz |