From ded8472f1d86b10be6672717d5d1c0eecbdd6796 Mon Sep 17 00:00:00 2001 From: berliner Date: Mon, 9 Dec 2024 13:22:26 +0100 Subject: [PATCH] HPC-9945: Don't show checkbox field in frontend view, fix an issue with rendered preview of interactive content paragraphs when displayed as part of a sub article in the content edit screen --- ..._display.paragraph.interactive_content.default.yml | 11 +---------- html/modules/custom/ncms_ui/css/frontend_styles.css | 4 ++++ .../common_design_subtheme.theme | 11 +++++++++++ .../paragraph--interactive-content.html.twig | 4 ++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/config/core.entity_view_display.paragraph.interactive_content.default.yml b/config/core.entity_view_display.paragraph.interactive_content.default.yml index b6a539a5..ac034be6 100755 --- a/config/core.entity_view_display.paragraph.interactive_content.default.yml +++ b/config/core.entity_view_display.paragraph.interactive_content.default.yml @@ -35,16 +35,6 @@ content: third_party_settings: { } weight: 3 region: content - field_full_width: - type: boolean - label: hidden - settings: - format: true-false - format_custom_false: '' - format_custom_true: '' - third_party_settings: { } - weight: 5 - region: content field_image: type: linked_responsive_image_media_formatter label: hidden @@ -75,6 +65,7 @@ content: weight: 0 region: content hidden: + field_full_width: true field_link: true field_show_datawrapper: true field_show_interactive_content: true diff --git a/html/modules/custom/ncms_ui/css/frontend_styles.css b/html/modules/custom/ncms_ui/css/frontend_styles.css index b60a0788..f1f70cf3 100644 --- a/html/modules/custom/ncms_ui/css/frontend_styles.css +++ b/html/modules/custom/ncms_ui/css/frontend_styles.css @@ -130,6 +130,10 @@ color: white; padding: 1em; } +.paragraph--type--sub-article .paragraph--type--interactive-content { + background: inherit; + color: inherit; +} /*------------------------------------------------------------------------------ * Styling of the Separator paragraph type diff --git a/html/themes/custom/common_design_subtheme/common_design_subtheme.theme b/html/themes/custom/common_design_subtheme/common_design_subtheme.theme index 6dd0f500..b32c1b40 100644 --- a/html/themes/custom/common_design_subtheme/common_design_subtheme.theme +++ b/html/themes/custom/common_design_subtheme/common_design_subtheme.theme @@ -227,6 +227,17 @@ function common_design_subtheme_preprocess_paragraph__image_with_text(&$variable } } +/** + * Implements hook_preprocess_paragraph__sub_article(). + * + * Add a class to the sub-article paragraph indicating whether the article has + * a hero or not as it's difficult to access from within the twig templates. + */ +function common_design_subtheme_preprocess_paragraph__interactive_content(&$variables) { + $paragraph = $variables['paragraph']; + $variables['full_width'] = $paragraph->hasField('field_full_width') && $paragraph->get('field_full_width')->value; +} + /** * Implements hook_preprocess_paragraph__section_index(). * diff --git a/html/themes/custom/common_design_subtheme/templates/paragraphs/paragraph--interactive-content.html.twig b/html/themes/custom/common_design_subtheme/templates/paragraphs/paragraph--interactive-content.html.twig index 6292343b..fcaeeb7e 100644 --- a/html/themes/custom/common_design_subtheme/templates/paragraphs/paragraph--interactive-content.html.twig +++ b/html/themes/custom/common_design_subtheme/templates/paragraphs/paragraph--interactive-content.html.twig @@ -50,7 +50,7 @@ not paragraph.isPublished() ? 'paragraph--unpublished', 'gho-aside', 'gho-interactive-content', - content.field_full_width|render|striptags|trim|lower == 'true' ? 'gho-interactive-content--full-width' : 'content-width', + full_width ? 'gho-interactive-content--full-width' : 'content-width', ] %} {% block paragraph %} @@ -65,7 +65,7 @@ {% else %} {{ content.field_image }} {% endif %} - {{ content|without(['field_type', 'field_title', 'field_embed_code', 'field_image', 'field_show_interactive_content', 'field_full_width']) }} + {{ content|without(['field_type', 'field_title', 'field_embed_code', 'field_image', 'field_show_interactive_content']) }} {% endblock %} {% endblock paragraph %}