2011-02-16 48 views

回答

1

你應該在用戶會話當前語言存儲,那麼如果它改變,重定向到頭版,然後設置這個會話改變語言。
在你的template.php:

/** 
* Override or insert variables into the page templates. 
* 
* @param $vars 
* An array of variables to pass to the theme template. 
* @param $hook 
* The name of the template being rendered ("page" in this case.) 
*/ 
function THEMENAME_preprocess_page(&$vars, $hook) { 
    global $language; 
    $currentlanguage = isset($_SESSION['currentlanguage']) ? $_SESSION['currentlanguage'] : $language->language; 
    if ($language->language != $currentlanguage) { 
    drupal_goto(url().'/'.$language->language); //goto current language version, if you use http://SITEURL/{languagecode} version, otherwise change it to appropriate. 
    } 
} 
+0

我在哪裏可以把這個代碼,我在哪裏設置會話?我對Drupal很新。抱歉是一個新手。 – 2011-02-16 03:08:38

1

在Drupal 6中寫的template.php:

function THEMENAME_preprocess_page(&$vars, $hook) { 
    global $language; 
    $previouselanguage = isset($_SESSION['previouselanguage']) ? $_SESSION['previouselanguage'] : $language->language; 
    $_SESSION['previouselanguage'] = $language->language; 
    if ($language->language != $previouselanguage) { 
    drupal_goto(''); 
    } 
}