diff --git a/config/core.entity_form_display.node.story.default.yml b/config/core.entity_form_display.node.story.default.yml index 83290307..58cb2bde 100755 --- a/config/core.entity_form_display.node.story.default.yml +++ b/config/core.entity_form_display.node.story.default.yml @@ -3,6 +3,7 @@ langcode: en status: true dependencies: config: + - field.field.node.story.field_caption - field.field.node.story.field_content_space - field.field.node.story.field_footnotes - field.field.node.story.field_media @@ -13,6 +14,7 @@ dependencies: module: - allowed_formats - content_moderation + - double_field - media_library - text id: node.story.default @@ -20,6 +22,33 @@ targetEntityType: node bundle: story mode: default content: + field_caption: + type: double_field + weight: 4 + region: content + settings: + first: + type: textfield + label_display: block + size: 60 + placeholder: 'Ex: Mbuji-Mayi, RDC' + label: Ok + cols: 10 + rows: 5 + prefix: '' + suffix: '' + second: + type: textarea + label_display: block + size: 10 + placeholder: '' + label: Ok + cols: 10 + rows: 5 + prefix: '' + suffix: '' + inline: false + third_party_settings: { } field_content_space: type: options_select weight: 0 @@ -28,7 +57,7 @@ content: third_party_settings: { } field_footnotes: type: text_textarea - weight: 5 + weight: 6 region: content settings: rows: 5 @@ -46,7 +75,7 @@ content: third_party_settings: { } field_source: type: text_textarea - weight: 6 + weight: 7 region: content settings: rows: 5 @@ -57,7 +86,7 @@ content: hide_guidelines: '1' field_text: type: text_textarea - weight: 4 + weight: 5 region: content settings: rows: 5 @@ -74,13 +103,13 @@ content: third_party_settings: { } moderation_state: type: moderation_state_default - weight: 8 + weight: 9 region: content settings: { } third_party_settings: { } status: type: boolean_checkbox - weight: 7 + weight: 8 region: content settings: display_label: true diff --git a/config/core.entity_view_display.node.story.default.yml b/config/core.entity_view_display.node.story.default.yml index fc2f705f..79aee67b 100755 --- a/config/core.entity_view_display.node.story.default.yml +++ b/config/core.entity_view_display.node.story.default.yml @@ -3,6 +3,7 @@ langcode: en status: true dependencies: config: + - field.field.node.story.field_caption - field.field.node.story.field_content_space - field.field.node.story.field_footnotes - field.field.node.story.field_media @@ -11,6 +12,7 @@ dependencies: - field.field.node.story.field_type - node.type.story module: + - gho_fields - text - user id: node.story.default @@ -18,6 +20,13 @@ targetEntityType: node bundle: story mode: default content: + field_caption: + type: gho_caption + label: hidden + settings: { } + third_party_settings: { } + weight: 6 + region: content field_footnotes: type: text_default label: above diff --git a/config/core.entity_view_display.node.story.full.yml b/config/core.entity_view_display.node.story.full.yml new file mode 100644 index 00000000..d3d69949 --- /dev/null +++ b/config/core.entity_view_display.node.story.full.yml @@ -0,0 +1,50 @@ +uuid: 66a0c6ee-2406-498b-9756-620fb42f3b09 +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.full + - field.field.node.story.field_caption + - field.field.node.story.field_content_space + - field.field.node.story.field_footnotes + - field.field.node.story.field_media + - field.field.node.story.field_source + - field.field.node.story.field_text + - field.field.node.story.field_type + - node.type.story + module: + - gho_fields + - user +id: node.story.full +targetEntityType: node +bundle: story +mode: full +content: + field_caption: + type: gho_caption + label: hidden + settings: { } + third_party_settings: { } + weight: 4 + region: content + links: + settings: { } + third_party_settings: { } + weight: 100 + region: content + title: + type: string + label: hidden + settings: + link_to_entity: false + third_party_settings: { } + weight: -5 + region: content +hidden: + field_content_space: true + field_footnotes: true + field_media: true + field_source: true + field_text: true + field_type: true + langcode: true diff --git a/config/core.entity_view_display.node.story.home_page.yml b/config/core.entity_view_display.node.story.home_page.yml new file mode 100644 index 00000000..45bc4d11 --- /dev/null +++ b/config/core.entity_view_display.node.story.home_page.yml @@ -0,0 +1,50 @@ +uuid: aa35d3d3-c347-415f-a191-94eb15cf4769 +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.home_page + - field.field.node.story.field_caption + - field.field.node.story.field_content_space + - field.field.node.story.field_footnotes + - field.field.node.story.field_media + - field.field.node.story.field_source + - field.field.node.story.field_text + - field.field.node.story.field_type + - node.type.story + module: + - gho_fields + - user +id: node.story.home_page +targetEntityType: node +bundle: story +mode: home_page +content: + field_caption: + type: gho_caption + label: hidden + settings: { } + third_party_settings: { } + weight: 4 + region: content + links: + settings: { } + third_party_settings: { } + weight: 100 + region: content + title: + type: string + label: hidden + settings: + link_to_entity: false + third_party_settings: { } + weight: -5 + region: content +hidden: + field_content_space: true + field_footnotes: true + field_media: true + field_source: true + field_text: true + field_type: true + langcode: true diff --git a/config/core.entity_view_display.node.story.preview.yml b/config/core.entity_view_display.node.story.preview.yml index a852a5a8..760f9af3 100755 --- a/config/core.entity_view_display.node.story.preview.yml +++ b/config/core.entity_view_display.node.story.preview.yml @@ -4,6 +4,7 @@ status: true dependencies: config: - core.entity_view_mode.node.preview + - field.field.node.story.field_caption - field.field.node.story.field_content_space - field.field.node.story.field_footnotes - field.field.node.story.field_media @@ -71,6 +72,7 @@ content: weight: -5 region: content hidden: + field_caption: true field_content_space: true langcode: true links: true diff --git a/config/core.entity_view_display.node.story.teaser.yml b/config/core.entity_view_display.node.story.teaser.yml index 5aff49a3..0f33fecc 100755 --- a/config/core.entity_view_display.node.story.teaser.yml +++ b/config/core.entity_view_display.node.story.teaser.yml @@ -4,6 +4,7 @@ status: true dependencies: config: - core.entity_view_mode.node.teaser + - field.field.node.story.field_caption - field.field.node.story.field_content_space - field.field.node.story.field_footnotes - field.field.node.story.field_media @@ -12,6 +13,7 @@ dependencies: - field.field.node.story.field_type - node.type.story module: + - double_field - text - user id: node.story.teaser @@ -19,12 +21,36 @@ targetEntityType: node bundle: story mode: teaser content: + field_caption: + type: double_field_unformatted_list + label: hidden + settings: + first: + format_type: medium + link: false + hidden: false + key: false + decimal_separator: . + thousand_separator: '' + scale: 2 + second: + format_type: medium + link: false + hidden: false + key: false + decimal_separator: . + thousand_separator: '' + scale: 2 + inline: true + third_party_settings: { } + weight: 3 + region: content field_footnotes: type: text_default label: above settings: { } third_party_settings: { } - weight: 3 + weight: 5 region: content field_media: type: entity_reference_entity_view @@ -33,21 +59,21 @@ content: view_mode: story link: false third_party_settings: { } - weight: 1 + weight: 2 region: content field_source: type: text_default label: above settings: { } third_party_settings: { } - weight: 4 + weight: 6 region: content field_text: type: text_default label: hidden settings: { } third_party_settings: { } - weight: 2 + weight: 4 region: content field_type: type: entity_reference_label @@ -55,7 +81,7 @@ content: settings: link: false third_party_settings: { } - weight: 0 + weight: 1 region: content title: type: string @@ -63,7 +89,7 @@ content: settings: link_to_entity: false third_party_settings: { } - weight: -5 + weight: 0 region: content hidden: field_content_space: true diff --git a/config/field.field.node.story.field_caption.yml b/config/field.field.node.story.field_caption.yml new file mode 100644 index 00000000..354e4066 --- /dev/null +++ b/config/field.field.node.story.field_caption.yml @@ -0,0 +1,39 @@ +uuid: 727f2c1b-3db9-4588-b276-40b695622243 +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_caption + - node.type.story + module: + - double_field +id: node.story.field_caption +field_name: field_caption +entity_type: node +bundle: story +label: Caption +description: 'When this image is used on Humanitarian Action, it will include a written text comprising the location in bold, followed by the caption, and then the image credits. These credits are defined in the Media Library and not editable here.' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + first: + label: 'Image location' + list: false + allowed_values: { } + max: null + min: null + required: false + on_label: 'On' + off_label: 'Off' + second: + label: Caption + list: false + allowed_values: { } + max: null + min: null + required: false + on_label: 'On' + off_label: 'Off' +field_type: double_field diff --git a/html/modules/custom/ncms_ui/ncms_ui.module b/html/modules/custom/ncms_ui/ncms_ui.module index a9fbeb32..dfd445fc 100644 --- a/html/modules/custom/ncms_ui/ncms_ui.module +++ b/html/modules/custom/ncms_ui/ncms_ui.module @@ -337,15 +337,11 @@ function ncms_ui_form_node_form_alter(&$form, FormStateInterface $form_state) { ]; if ($node instanceof Document) { - // Hide the label of the double field widget. - $form['field_caption']['widget'][0]['#title_display'] = FALSE; // Attach custom styles. $form['#attached']['library'][] = 'ncms_ui/document_edit_form'; } if ($node instanceof Article) { - // Hide the label of the double field widget. - $form['field_caption']['widget'][0]['#title_display'] = FALSE; // Attach custom styles. $form['#attached']['library'][] = 'ncms_ui/article_edit_form'; } @@ -368,6 +364,11 @@ function ncms_ui_form_node_form_alter(&$form, FormStateInterface $form_state) { $entity_overview_form_alter->alterForm($form, $form_state); } + // Hide the label of the double field widget. + if (array_key_exists('field_caption', $form)) { + $form['field_caption']['widget'][0]['#title_display'] = FALSE; + } + // Add a cancel link. This either redirects to the publisher site if this // request came from an external publisher, or to a url given in the // destination query argument, or, as a fallback, to the main content 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 9300709d..32831856 100644 --- a/html/themes/custom/common_design_subtheme/common_design_subtheme.theme +++ b/html/themes/custom/common_design_subtheme/common_design_subtheme.theme @@ -169,7 +169,24 @@ function common_design_subtheme_preprocess_node(&$variables) { function common_design_subtheme_preprocess_node__story(&$variables) { if (isset($variables['content']['field_media'][0]['#media'])) { $credits = $variables['content']['field_media'][0]['#media']->field_credits->value; - $variables['content']['credits'] = ['#markup' => $credits]; + + if ($variables['content']['field_caption']) { + // Move the caption into the markup of the media field. + $variables['content']['field_caption']['#prefix'] = '
'; + $variables['content']['field_caption']['#suffix'] = '
'; + $variables['content']['field_caption'][] = [ + '#type' => 'html_tag', + '#tag' => 'span', + '#attributes' => [ + 'class' => [ + 'gho-caption__credits', + ], + ], + '#value' => $credits, + ]; + $variables['content']['field_media'][0][] = $variables['content']['field_caption']; + $variables['content']['field_caption']['#access'] = FALSE; + } } } diff --git a/html/themes/custom/common_design_subtheme/components/gho-story/gho-story.css b/html/themes/custom/common_design_subtheme/components/gho-story/gho-story.css index aa54ded0..aa59f7ee 100644 --- a/html/themes/custom/common_design_subtheme/components/gho-story/gho-story.css +++ b/html/themes/custom/common_design_subtheme/components/gho-story/gho-story.css @@ -54,6 +54,27 @@ .gho-story .field--name-field-media { margin-bottom: 2rem; } +.gho-story .field--name-field-media .media--view-mode-story { + position: relative; +} +.gho-story .field--name-field-media .media-caption { + position: absolute; + bottom: 1rem; + right: 1rem; + background-color: var(--cd-white); + opacity: 0.9; + font-size: var(--cd-font-size--tiny); + padding: 0.5rem 1rem; + max-width: 70%; +} +.gho-story .field--name-field-media .media-caption * { + display: inline; + color: var(--cd-default-text-color); +} +.gho-story .field--name-field-media .media-caption .double-field-first { + font-weight: bold; + display: block; +} .gho-story .gho-caption { margin: 0; } diff --git a/html/themes/custom/common_design_subtheme/templates/nodes/node--story--full.html.twig b/html/themes/custom/common_design_subtheme/templates/nodes/node--story--full.html.twig index 732ca162..d9ed672a 100644 --- a/html/themes/custom/common_design_subtheme/templates/nodes/node--story--full.html.twig +++ b/html/themes/custom/common_design_subtheme/templates/nodes/node--story--full.html.twig @@ -114,11 +114,10 @@
{{ content.field_text }} - {{ content.credits }}
- {{ content|without(['field_type', 'field_media', 'field_text', 'credits']) }} + {{ content|without(['field_type', 'field_media', 'field_text']) }} {# diff --git a/html/themes/custom/common_design_subtheme/templates/nodes/node--story--teaser.html.twig b/html/themes/custom/common_design_subtheme/templates/nodes/node--story--teaser.html.twig index f37d165f..c96ee840 100644 --- a/html/themes/custom/common_design_subtheme/templates/nodes/node--story--teaser.html.twig +++ b/html/themes/custom/common_design_subtheme/templates/nodes/node--story--teaser.html.twig @@ -101,10 +101,9 @@
{{ content.field_text }} - {{ content.credits }}
- {{ content|without(['field_type', 'field_media', 'field_text', 'credits']) }} + {{ content|without(['field_type', 'field_media', 'field_text']) }} {#