Score:0

Set a page for different languages?

in flag

Is there a way to specify the front page per language of a Drupal 9 site? I am looking for an interface that allows this to be set by a user.

Score:0
de flag

If you want to allow user input, it's not an easy task. I would do the following:

  1. Create a custom form (not a configuration form), using the Form API, that allows the user to input the path to the front page. https://www.drupal.org/docs/drupal-apis/form-api/introduction-to-form-api

    How you work this form to manage the language is up to you - you could either use the current interface language, or you could add an additional input for language on the form.

  2. In the submit handler for the form, save the submitted values to the Drupal State, using the State API. The State API is environment-specific storage, it is not exported/imported with configuration between environments. https://www.drupal.org/docs/8/api/state-api/overview

  3. Dynamically override the system.site.page.front configuration, using the value retrieved from the state for the current language. https://www.drupal.org/docs/drupal-apis/configuration-api/configuration-override-system#s-providing-overrides-from-modules

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.