Search code examples
drupaldrupal-7

Drupal 7: different homepage template for different language


I have a site on Drupal7 using multilingual plugin. I have 4 languages and I need to make a completely different homepage for one of langugaes (let's say Russian version).

I followed these articles: How can I set a different homepage per language in Drupal? https://www.drupal.org/node/1216132

They work only partially. Because now my Russian homepage:

  • has content of the choosen node (that's right)
  • has template (page--front.tpl.php) of the front page instead of the appropriate template.

And it creates unwanted effect: I have the right content in the page view.

I don't know if a former developer of the website made it or it's a drupal mistake.

Could anybody give me a hint, please?


Solution

  • So, all what you want is to use different page templates for different languages? This can easily be done in your MODULE_preprocess_page or THEME_preprocess_page function:

    function mytheme_preprocess_page(&$variables) {
      $language = $variables['language'];
      $variables['theme_hook_suggestions'][] = 'page__front__' . $language->language;
    }
    

    Now the system will search for page--front--en.tpl.php etc. templates.

    The function mytheme_preprocess_page can be found in: /sites/all/themes/mytheme/template.php

    Also take a look at Working with template suggestions.