diff --git a/metatag.module b/metatag.module index 1b0e243..879a3e6 100644 --- a/metatag.module +++ b/metatag.module @@ -851,21 +851,22 @@ function metatag_page_get_metatags() { * Implements hook_page_build(). */ function metatag_page_build(&$page) { - // Ensure that this array exists, otherwise several use cases will fail. - if (!isset($page['content'])) { + // Ensure these arrays exist, otherwise several use cases will fail. + if (!isset($page['content']) || !is_array($page['content'])) { $page['content'] = array(); } + if (!isset($page['content']['metatags']) || !is_array($page['metatags'])) { + $page['content']['metatags'] = array(); + } - // Load the metatags render array in before any page content so that more - // more specific meta tags in the page content can override these meta tags. - $page['content'] = array('metatags' => metatag_page_get_metatags()) + $page['content']; - + // The front page has special consideration. if (drupal_is_front_page()) { $page['content']['metatags']['global:frontpage'] = metatag_metatags_view('global:frontpage', array()); } - elseif (!path_is_admin(current_path())) { - // Do not output the global metatags when on an administration path. - $page['content']['metatags']['global'] = metatag_metatags_view('global', array()); + // Load any meta tags assigned via metatag_page_set_metatags(). Note: this + // must include the necessary defaults. + else { + $page['content']['metatags'] += metatag_page_get_metatags(); } }