Changing URI segments in Code Ingniter |
[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
[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
[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?
[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
[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 |
Welcome Guest, Not a member yet? Register Sign In |