Easy way to switch language |
[eluser]imn.codeartist[/eluser]
Create a library named MY_Controller.php and place in your system/application/libraries and paste the code below Code: class Front_Controller extends Controller Create your controller and extend it with Front_Controller class For example: Code: class Home extends Front_Controller And create home.php and place in the views: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> You are done.
[eluser]eoinmcg[/eluser]
Hi dixcoder, In the past I used a similar approach, though changing the language via session, rather than the url, means that the non default language versions are going to be invisible to search engines. If you're interested take a look at http://codeigniter.com/wiki/URI_Language_Identifier/ http://maestric.com/doc/php/codeigniter_i18n
[eluser]imn.codeartist[/eluser]
thank you for your reply, well i also have provided the hyperlink to change the language where it takes different languages as parameter for example http://www.example.com/set_language/english so shouldn't be the problem for search engine ...mmm... what do you say?
[eluser]eoinmcg[/eluser]
maybe i read your post too fast or misunderstood something... is the change of language evident in the URL or simply by changing session state? what mean to say is that using sessions/ cookies to transfer such info is going to be invisible to search engines...
[eluser]liri[/eluser]
Any ideas why am I getting an error of "Fatal error: Call to a member function set_userdata() on a non-object in /var/www/..." which is this part of code: Code: $this->session->set_userdata('language', strtolower($language));
[eluser]liri[/eluser]
Ok so, Seems like I needed to load the session library in each controller (parent and child). Is this how it should be? Secondly, what is the code in the front controller's construct for about item data? seems like it's never get read to there or written to there at all? I'm talking about: Code: if($this->session->userdata('language'))
[eluser]ADujmovic[/eluser]
Hi, I need some help with this code here. I'm trying to implement this code with my solution and it is not working. I did all the steps but when I clickc on the link i get 404 message! Any tips? |
Welcome Guest, Not a member yet? Register Sign In |