diff --git a/changelogs/DP-46271.yml b/changelogs/DP-46271.yml new file mode 100644 index 0000000000..93050cc5b8 --- /dev/null +++ b/changelogs/DP-46271.yml @@ -0,0 +1,3 @@ +Fixed: + - description: Fix press release city injection to use the first paragraph even when the first p tag has attributes like lang. + issue: DP-46271 diff --git a/docroot/themes/custom/mass_theme/mass_theme.theme b/docroot/themes/custom/mass_theme/mass_theme.theme index be2e019302..eb23a875cb 100644 --- a/docroot/themes/custom/mass_theme/mass_theme.theme +++ b/docroot/themes/custom/mass_theme/mass_theme.theme @@ -3497,11 +3497,8 @@ function mass_theme_preprocess_node_news_full(&$variables) { $location = Helper::fieldFullView($node, $field['location']); $location_string = \Drupal::service('renderer')->renderRoot($location); $location = '' . $location_string . ' — '; - $body_array = explode('

', $body_string); - if (count($body_array) > 1) { - $body_array[1] = $location . $body_array[1]; - } - $body_string = implode('

', $body_array); + // Prefix the first paragraph content, regardless of attributes like lang. + $body_string = preg_replace('/(<\s*p\b[^>]*>)/i', '$1' . $location, $body_string, 1); } if (Helper::fieldValue($node, $field['news_type']) == 'press_release') { $ap_conformity = TRUE;