Welcome Guest, Not a member yet? Register   Sign In
Updating URL based on language selection and displaying translated page


This issue is driving me crazy! I'll try to be brief. I have a dropdown menu that holds several languages. Upon submission I'm basically trying to accomplish two things:

1. I need my URL to update, it means my new URL would look something like this (for example): www.mydomain.com/sp/something.php It basically inserts the language key.

2. In my default controller within my index(), I need to process $this->input->post('lang') so that I'm able to load a number of content files whose variables will be passed into $this->smarty->assign(), and finally display my page with my translated content. Here's my index function:

function index($page = 'home')      
  not_found($page);        // Quit if page is not found

  $language = $this->multilanguage->language;  // Default lang if no input lang is selected from dropdown
  // Load files
  // Assign variables
  $this->smarty->assign('url',$this->multilanguage->url_to_be_assigned($page)); // URL assigned for switching language
  $this->smarty->assign('title',title($page));    // title() helper used
  $this->smarty->assign('meta',meta($meta[$page]));   // meta() helper passes array of meta tags based on input page  
  $this->smarty->assign('data',$data);      // Main content
   isset($_SESSION['poll_result']) ? $this->poll_result() : $this->poll_item();
   $this->smarty->assign('poll', ob_get_contents());
  // Display template based on input


The question:

How do I update my URL upon submission if in order to read the selected language by the user it first has to go through my index function? In other words, On the FIRST submission I need to insert the key into my URL and then assign and display my page with the translated content, how do I do that? what would the 'action' attribute in the dropdown form look like?

If anything is unclear please don't hesitate to ask. Anything, I mean any thing you tell/suggest/recommend me will be much appreciated.

Messages In This Thread
Updating URL based on language selection and displaying translated page - by El Forum - 06-06-2013, 06:10 PM

Theme © iAndrew 2016 - Forum software by © MyBB