multilanguage database struct |
[eluser]davidino86[/eluser]
Hi, I'm developing a multilanguage cms and i like to know the best way to structure my DB for the best frontend control with the multilanguage library of codeigniter. so when i have in the URL en or it the query take the right record. i hope in your help, regards
[eluser]Isern Palaus[/eluser]
Hello, I have a table called 'idioma' (language in spanish): Code: CREATE TABLE IF NOT EXISTS `idioma` ( nombre -> name codigo -> code locale -> locale imagen -> image orden -> order activo -> active fecha -> date I add entries like: Name = English, Code = EN, Locale = en_US, Image = en.jpg, Order = 1, Active = 1, Date = 2010-02-17. Then, to detect the language I personally use URI Language founded on the wiki for the detect the languages like .com/en, .com/es, .com/fr... and my BaseController (that I extend on every controller) looks like: Code: <?php And in the MY_Language.php helper: Code: function getLanguage() So I can access in every controller with $this->idioma. Then all my tables that contents multilingual content has this structure: news ---- idnews image user_id date news_description ---------------- idnews_description text news_idnews idioma_ididioma Then for every new you will add a text for every language. A query will look like: Code: public function get_new($idnews = 1, $ididioma = 1) And you will call it with get_news($new_id, $this->idioma). I wish it helps and sorry for my school English. Regards, Isern
[eluser]siubie[/eluser]
hai isern i try your solution but when i use print $this->idoma there is notthing appear ? where do i wrong i use URI Language Identifier from wiki this is my file Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); and my baseController.php Code: <?php
[eluser]Isern Palaus[/eluser]
Hi siubie, Seems to be all fine... Do you extend "BaseController" correctly, no? Whis it helps! Isern
[eluser]siubie[/eluser]
this is my controller is this the right way to extend the class? Code: <?php
[eluser]Isern Palaus[/eluser]
This is the way to do it: Code: <?php Put the 'BaseController.php' in your /libraries folder inside the application folder. Note that I changed parent::Controller(); to parent::BaseController(); Have you got a record inside your database that matches with the language abbreviation on the URI?
[eluser]siubie[/eluser]
I have change the code, i move BaseController.php to /libraries in the application folder but it comes with error : Fatal error: Class 'BaseController' not found and in my database i have the record that matches the language abbreviation.
[eluser]Isern Palaus[/eluser]
mmmm... so strange. Can you e-mail me the application folder zipped to [email protected] ? And I will look for the problem.
[eluser]siubie[/eluser]
ok i will send it asap a million thanks for you isern ![]() |
Welcome Guest, Not a member yet? Register Sign In |