![]() |
Remap Controller - 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: Remap Controller (/showthread.php?tid=5572) |
Remap Controller - El Forum - 01-26-2008 [eluser]breaddes[/eluser] I have an url that goes like this: Code: <a href="<?=base_url().$this->lang('glossary')?>"><?=$this->lang->('glossary')?></a> $this->lang('glossary') is the glossary in a certain language. It can be French, German, Swedish or English. However, in the German case the output looks like: Code: <a href="http://localhost/Glossar">Glossar</a> The thing is that I don't have a specific controller for each language. I have just one controller that's in the English language. So it is glossary. How can I remap all the different urls to the english name? I think there's a solution using routes, if I do it static: Code: $route['glossar'] = "glossary"; That works fine for the German version, but I'd like to set a dynamic version ... so it would be something like: Code: $route[$this->lang('glossary')] = "glossary"; As the routeshelper is already loaded, that won't work out pretty well. Any ideas? Remap Controller - El Forum - 01-27-2008 [eluser]xwero[/eluser] I did this week something similar. I made a pages module where users add their own pages and the titles are converted to urls. The solution i used is add the language to the url and check if the page name exists in the database using the language from the url as a limiter. Using a language file is a bit more difficult because it's a static file and the language class is instantiated after the router class. You could try to use a pre controller hook to process the urls. Remap Controller - El Forum - 01-27-2008 [eluser]breaddes[/eluser] yeh that sounds like a good idea. I've created a controller 'routes' that is responsible for analyzing the urls and forward them. |