2

I am building multilingual site using 3 languages. English is default and 2 other used wit prefixes. www.example.com/fr/.../cs/

I would like to create custom landing page on www.example.com using different template than other landing pages with prefixes.

So www.example.com (which is English language) would only be plain page (custom template) with links to www.example.om/fr (with default template page) and to www.example.com/cs (default template)

Would be something like this possible?

Thank you

  • Which (major) version of Drupal are you using for the site? – Madis Jan 14 '12 at 10:49
  • Sorry I forgot to mention - it is drupal 6 – loparr Jan 14 '12 at 11:59
1

Create a custom template file for the English landing page first (for example: page-customfront.tpl.php) then add the following code into your theme template.php file:

function mytheme_preprocess_page(&$variables) {
  global $language;
  if (drupal_is_front_page() && $language->language == 'en') {
    $variables['template_file'] = 'page-customfront';
  }
}

This should do the trick (assuming English will remain the default language with no prefix). Don't forget to switch out mytheme in the function name with your actual theme name.

As for the language links you could use the following code:

<?php
$langs = language_list();
foreach ($langs as $lang) {
  if ($lang->enabled) {
    if ($lang->language == 'en') continue;
    print l($lang->native, '<front>', array('language' => $lang));
  }
}
?>

This should go into page-customfront.tpl.php in the place where you want the links to appear. If you are familiar with creating custom modules or don't mind learning it would probably be preferable to turn this code into a function, add it your module file, enable the module and then just call the function from page-customfront.tpl.php.

|improve this answer|||||
  • Ok I will try that and let you know today. I am planning to add more languages in the future - all with prefixes, english language as well. Now I don't use it for customers - that is why I don't need prefix. What would I need to do to have www.example.com as a custom template with links to default templates with language prefixes? Thank you very much for answer. – loparr Jan 14 '12 at 14:56
  • This solution worked perfectly. Would you be so kind and tell me somution for my second quiestion? Thank you very much – loparr Jan 14 '12 at 18:05
  • Added the answer to your second question in my post. Hope it helps. – Madis Jan 14 '12 at 19:04
  • Hi,I added the second code inside the page-customfront.tpl.php but it shows only 2 other languages and not english. I need it to show all available languages so the customer can choose from them. Why is it better to make custom module and to avoid such code with links to be put into page? Thank you – loparr Jan 14 '12 at 20:37
  • 1
    To my knowledge you can't make www.example.com independent. I would suggest adding a second custom English language with "en" prefix, which would get you the result you want. The original English would then only be used for www.example.com while the other English would act as the actual English language of the site. I've used this approach myself a lot (for a different purpose though) and it works well. If necessary you could also switch the roles of the custom and original English languages. – Madis Jan 14 '12 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.