开发者

Drupal language negotiation

I have a mul开发者_开发知识库ti-language drupal setup (2 languages, english default). I want users to receive always content in the other language (lets say spanish) on initial page request, but keep english as default language for future language switch. So users will be redirected on initial load to site.com/es, but through the language switch will be able to go to site.com/ (which is english).

Any suggestions? Thank you.

(Apache, PHP)


Redirect users using preprocess in template.php file of your theme:
Approximate code:


/**
 * 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;
  if ($language->language == 'en') { // Add here some checking for page, see print_r($vars)
    drupal_goto(url().'/es/'.$GET['q']); //goto es version
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜