Skip to content
Snippets Groups Projects
Verified Commit 7f5a4bc4 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3043646 by tedbow, lauriii, bnjmnm, xjm, tim.plunkett, effulgentsia,...

Issue #3043646 by tedbow, lauriii, bnjmnm, xjm, tim.plunkett, effulgentsia, DyanneNova, webchick: For sites that have made layout overrides prior to 8.7.0 or sites that manually enable translation of the layout override field, add UI warnings

(cherry picked from commit a83655a4)
parent e7a41009
No related branches found
No related tags found
No related merge requests found
......@@ -255,6 +255,7 @@ function _content_translation_preprocess_language_content_settings_table(&$varia
'class' => ['operations'],
],
],
'#field_name' => $field_name,
'class' => ['field-settings'],
];
......
/* @todo Move this to Seven as part of https://www.drupal.org/node/3041053 */
.layout-builder-translation-warning {
background: left 2px url(../../../misc/icons/e29700/warning.svg) no-repeat;
padding-left: 20px;
}
......@@ -27,3 +27,9 @@ fourcol_section:
css:
theme:
layouts/fourcol_section/fourcol_section.css: {}
drupal.layout_builder_content_translation_admin:
version: VERSION
css:
theme:
css/layout-builder-content-translation.css: {}
......@@ -367,3 +367,46 @@ function layout_builder_entity_translation_create(EntityInterface $translation)
$translation->set(OverridesSectionStorage::FIELD_NAME, []);
}
}
/**
* Implements hook_theme_registry_alter().
*/
function layout_builder_theme_registry_alter(&$theme_registry) {
// Move our preprocess to run after
// content_translation_preprocess_language_content_settings_table().
if (!empty($theme_registry['language_content_settings_table']['preprocess functions'])) {
$preprocess_functions = &$theme_registry['language_content_settings_table']['preprocess functions'];
$index = array_search('layout_builder_preprocess_language_content_settings_table', $preprocess_functions);
if ($index !== FALSE) {
unset($preprocess_functions[$index]);
$preprocess_functions[] = 'layout_builder_preprocess_language_content_settings_table';
}
}
}
/**
* Implements hook_preprocess_HOOK() for language-content-settings-table.html.twig.
*/
function layout_builder_preprocess_language_content_settings_table(&$variables) {
foreach ($variables['build']['#rows'] as &$row) {
if (isset($row['#field_name']) && $row['#field_name'] === OverridesSectionStorage::FIELD_NAME) {
// Rebuild the label to include a warning about using translations with
// layouts.
$row['data'][1]['data']['field'] = [
'label' => $row['data'][1]['data']['field'],
'description' => [
'#type' => 'container',
'#markup' => t('<strong>Warning</strong>: Layout Builder does not support translating layouts. (<a href="https://www.drupal.org/docs/8/core/modules/layout-builder/layout-builder-and-content-translation">online documentation</a>)'),
'#attributes' => [
'class' => ['layout-builder-translation-warning'],
],
'#attached' => [
'library' => [
'layout_builder/drupal.layout_builder_content_translation_admin',
],
],
],
];
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment