CodeIgniter Forums
Controller Sub-Folders? - 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: Controller Sub-Folders? (/showthread.php?tid=11926)



Controller Sub-Folders? - El Forum - 09-28-2008

[eluser]Moon 111[/eluser]
My website has two languages so I was going to have an english sub-folder and a hebrew sub-folder inside my controller folder. Is this not allowed?

How should I do this instead?

Thanks,
- Moshe


Controller Sub-Folders? - El Forum - 09-28-2008

[eluser]Developer13[/eluser]
Well, unless I'm missing the reason why you'd have a separate controller for each language, the reason the language library exists is so you can replace your variables with $this->lang->line('item') calls... so this begs the question, why do you want to have separate controllers for the different languages?


Controller Sub-Folders? - El Forum - 09-29-2008

[eluser]Moon 111[/eluser]
I don't know... How would you do it? I couldn't really think of anything...


Controller Sub-Folders? - El Forum - 09-29-2008

[eluser]Moon 111[/eluser]
I'm not fimiliar with $this->lang->line(). How does it work? The user guide is very vague...


Controller Sub-Folders? - El Forum - 09-29-2008

[eluser]xwero[/eluser]
As D13 i'm asking myself if you are really planning on having different controllers for the two languages or if you just want to add the language to the url?

If you are planning to have different controllers a language subdirectory is a good idea and it's possible to do this? So i'm wondering what is the problem you have?

If you are planning to add the language to the url but use the same controllers you can use routing to 'hide' the language form been seen as a part of the filepath/controller/function url structure CI uses.
Code:
$route['\w{2}/(.+)'] = '$1';
This route checks if the first segment has 2 letters, a forward slash and at least one character behind the forward slash. So site.com/en/1 would be routed to a controller with the name 1.
There are some other solutions mentioned on the forum you can do a search for multi language site or something like that.

The lang->line method just gets the word/phrase with the key you add as the first parameter. Of course you need to load the language file where the key and word/phrase for the particular language is stored.


Controller Sub-Folders? - El Forum - 09-29-2008

[eluser]Moon 111[/eluser]
I get an error... One second I'll post it.