multiple frontpages in multiple languages [closed]
Asked Answered
G

5

10

I have a Drupal 7 multi-language(3) website. I have installed the Internationalization (7.x-1.0-beta2) module.

I have created for each language a page, and translate it into two others languages.

Now here is what I want to do: to set a kind of intelligent "front-page" to know what language is selected and set the front page (which I choose) in that language.

How can I do this? I know that in Internationalization module, there is no such kind of thing, am I right? If I set the front page to nothing I get this message: “No front page content has been created yet.” which is normal because Drupal is asking me for one front-page to be set, however I want to have for each language a front-page.

Graniah answered 2/3, 2011 at 13:44 Comment(0)
T
34

Might be late to the party with this answer, but after many hours spent trying to solve this myself, I've the following solution.

For Drupal 7:

1- Make sure you have the modules Variable and Variable Translations switched on.
2- Goto admin/config/regional/i18n/variable
3- Select the 'Site information' list tab and check 'Default front page', save settings.
4- Goto admin/config/system/site-information, you'll notice a block of text there saying something about some of your settings being multilingual variables and a list of links for the languages you are running which allow you to set the settings for each language.

Now, this is where the real GOTCHA comes up... clicking those links and changing the settings does nothing. Your left with the same settings still for all languages. The way around this?

Check the URL you are currently on, the entire thing, so something like: http://www.example.com/en/admin/config/system/site-information/

Notice the language prefix there before /admin?? To change the settings for the other languages you want to use, switch the prefix in the URL and then make your changes. And now, as if by magic, multiple front pages, properly changing based on language.

This must be a bug in Drupal, I should get around to opening a ticket. But for now, if someone else comes across this, I hope it solves your problem too.

Transeunt answered 23/7, 2011 at 22:8 Comment(2)
Actually, nowadays the i18n module displays a language switcher at the top of admin pages with localized variables.Glider
Anyone stumbling upon this. As of Sept 2016, these steps still need to be done to a Drupal 7 install just to make it work. I am sure D8 is better/fixed as translation is done differently (but don;t take my word for it).Aquitaine
U
4

I've been searching for the same. I 'd like to recommend Drupal 7 - multi-lingual front page node which is complete and works perfectly for Drupal 7 projects.

Unbearable answered 24/7, 2012 at 11:12 Comment(0)
G
2

After continuing to rip my hair out over this, I found out that this feature is incompatible with anonymous page caching!

Go to /admin/config/development/performance and turn off page caching for anonymous users.

Gradey answered 4/6, 2012 at 15:32 Comment(0)
G
1

May be there is a better way but finally he is how I did.

I have added in template.php the following code:

/**
 * Implements hook_preprocess_page().
 */
function aelius_preprocess_page(&$vars) {
    if ($vars['is_front']) {
        $langcode = $GLOBALS['language']->language;

        if ($langcode == "en") {
            drupal_goto('home');
        } elseif ($langcode == "fr") {
            drupal_goto('accueil');
        }
    }
}
Graniah answered 18/3, 2011 at 13:25 Comment(1)
This causes an infinite loopArluene
H
0

I haven't worked with Drupal 7 i18n yet, but in Drupal 6 you would add a site_frontpage variable to $conf['i18n_variables'] in settings.php and then switch to each language in turn and set the frontpage on the site information page.

Alternatively, you can specify a condition in your theme front-page.tpl.php like so

Haggi answered 16/3, 2011 at 0:36 Comment(1)
Thanks for your answer. I have tried both methods but unfortunately are not working in Drupal 7.Graniah

© 2022 - 2024 — McMap. All rights reserved.