diff --git a/metatag.module b/metatag.module index ce1514c..d279659 100644 --- a/metatag.module +++ b/metatag.module @@ -405,7 +405,9 @@ function metatag_field_attach_view_alter(&$output, $context) { $entity = $context['entity']; list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity); - if (metatag_entity_supports_metatags($entity_type, $bundle) && $context['view_mode'] == 'full' && _metatag_entity_is_page($entity_type, $context['entity'])) { + // Page manager might send the field with '_custom' build mode, so let + // it pass. + if (metatag_entity_supports_metatags($entity_type, $bundle) && in_array($context['view_mode'], array('full', '_custom')) && _metatag_entity_is_page($entity_type, $context['entity'])) { $cid = "output:{$entity_type}:{$entity_id}"; if ($cache = cache_get($cid, 'cache_metatag')) { @@ -439,6 +441,14 @@ function metatag_field_attach_view_alter(&$output, $context) { // We have to add a '#field_type' property otherwise // rdf_field_attach_view_alter() freaks out. $output['metatags']['#field_type'] = NULL; + + if ($context['view_mode'] == '_custom' && $entity_type == 'node') { + // We need to register the node's metatag, so we can later fetch + // them. + // @see metatag_page_build(). + $node_metatags = &drupal_static(__FUNCTION__, array()); + $node_metatags[] =$output; + } } } @@ -746,6 +756,14 @@ function metatag_page_build(&$page) { // Do not output the global metatags when on an administration path. $page['content']['metatags']['global'] = metatag_metatags_view('global', array()); } + + // If we are viewing a node overriden by Page manager module, + // node_view_multiple() isn't invoked, thus with don't have + // $node['metatags] in the renderable element. + // We call the pre-regsitered node, so we can manually add it. + if ($node_metatags = drupal_static('metatag_field_attach_view_alter', array())) { + $page['content']['metatags']['node'] = $node_metatags; + } } /**