Problem/Motivation
Layout Builder only exposes its Layout local task on the default (original) translation of an entity.
Steps to reproduce
- Enable Layout Builder overrides for a content type and enable a second language with translation.
- Create a node and add a translation (e.g. English original + Arabic translation).
- Edit/view the node in the original language — the Layout tab is present in the toolbar/local tasks.
- Switch to the translation (e.g.
/ar/node/1/edit) — the Layout tab is gone.
Proposed resolution
Implement hook_menu_local_tasks_alter() to keep the Layout local task visible on non-default translations, pointing it at the layout page of the original language.
- Detect the Layout Builder override local task by its plugin id (
…layout_builder.overrides.<entity_type_id>.view). - Act only when the routed entity is a translatable content entity and is not the default translation (core already handles the default language).
- Repoint the tab URL to
layout_builder.overrides.<type>.viewwith the original language, so clicking Layout redirects the editor to the original-language layout page. - Evaluate access against the default translation by loading the
overridessection storage with the untranslated entity (rather thanUrl::access(), which re-loads the entity in the active content language and is always denied). This preserves the user's real layout permissions. - Add cache contexts
languages:language_contentanduser.permissions, plus the access result and entity as cacheable dependencies.
User interface changes
The Layout local task (and therefore the Seeds Toolbar entry) is now shown on translations for users who have permission to configure the layout. Selecting it navigates to the original-language layout page. No change on the default language.
Comments
Comment #3
ahmad-alyasaki commented