0

我在 Drupal 7 上有一个显示语言链接的多语言站点,如果节点的翻译不可用,我希望能够将用户重定向到主页。

有没有办法做到这一点?

4

1 回答 1

0

The easiest solution is to use this module: https://drupal.org/project/multilink. The problem is that Im not sure if this module can redirect to homepage.

The best solution is to create your custom module and implementes hook_node_view

function yourmodulename_node_view($node, $view_mode, $langcode){
    // show 404 page if current language does not match content node language
   global $language;
   if (!empty($node->language) && $node->language != $language->language) {
      drupal_goto('<front>');  
   }
}

Im not sure if this code works, but its the correct way.

Regards.

于 2013-09-12T07:34:49.537 回答