First stab
2 unresolved threads
2 unresolved threads
Closes #3455655
Merge request reports
Activity
Filter activity
- Resolved by Julian Pustkuchen
- Resolved by Julian Pustkuchen
- Resolved by Julian Pustkuchen
26 return; 27 } 28 // Overwrite the page heading: 29 $variables['content']['#title'] = $newPageHeadingString; 30 } 31 } 32 33 /** 34 * Implements hook_page_attachments(). 35 * 36 * Remove the page_heading metatag from the page attachments, as it isn't a 37 * "real" meta tag. 38 */ 39 function metatag_page_heading_page_attachments(array &$attachments) { 40 // Return early if there are no HTML head attachments. 41 if (!is_array($attachments['#attached']['html_head']) || empty($attachments['#attached']['html_head'])) { 35 * 36 * Remove the page_heading metatag from the page attachments, as it isn't a 37 * "real" meta tag. 38 */ 39 function metatag_page_heading_page_attachments(array &$attachments) { 40 // Return early if there are no HTML head attachments. 41 if (!is_array($attachments['#attached']['html_head']) || empty($attachments['#attached']['html_head'])) { 42 return; 43 } 44 // If the "page_heading" metatag is present, remove it from the page 45 // attachments, as it isn't a "real" meta tag: 46 foreach ($attachments['#attached']['html_head'] as $key => $headAttachment) { 47 if ($headAttachment[1] === 'page_heading') { 48 unset($attachments['#attached']['html_head'][$key]); 49 } 50 } Sorry, I thought you wanted to unset() in array_filter() and I wondered how that would look
But yea filtering
$attachments['#attached']['html_head']
and reassigning it is way cleaner! Agreed(Adjusted in https://www.drupal.org/project/metatag_page_heading)
Edited by Joshua Sedler
- Resolved by Julian Pustkuchen
Please register or sign in to reply