Commit e0b1e989 authored by git's avatar git Committed by Damien McKenna
Browse files

Issue #3037874 by Ronino: Build meta tags for Panels much later so they can be...

Issue #3037874 by Ronino: Build meta tags for Panels much later so they can be altered after page data has been processed.
parent 32ea2c0d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ Metatag 7.x-1.x, xxxx-xx-xx
#3044943 by thejimbirch, mluzitano, DamienMcKenna: Fix LICENSE.txt.
#3037897 by Ronino, DamienMcKenna: Allow raw meta tags to be modified prior to
  creating the render array.
#3037874 by Ronino: Build meta tags for Panels much later so they can be altered
  after page data has been processed.


Metatag 7.x-1.25, 2018-04-03
+20 −18
Original line number Diff line number Diff line
@@ -135,13 +135,30 @@ function metatag_panels_form_submit($form, $form_state) {
 * Implements hook_ctools_render_alter().
 */
function metatag_panels_ctools_render_alter($info, $page, $context) {
  // Save the data necessary for metatag_panels_page_build() to build the meta
  // tags later. Don't build them here yet as this is before any
  // hook_page_build() has run which means some data to alter the meta tags in
  // hook_metatag_metatags_view() might not exist yet.
  $static = &drupal_static('metatag_panels');
  $static['context'] = $context;
  $static['info'] = $info;
}

/**
 * Implements hook_page_build().
 *
 * @see metatag_panels_ctools_render_alter()
 */
function metatag_panels_page_build(&$page) {
  // By default do not add meta tags to admin pages. To enable meta tags on
  // admin pages set the 'metatag_tag_admin_pages' variable to TRUE.
  if (path_is_admin(current_path()) && !variable_get('metatag_tag_admin_pages', FALSE)) {
    return;
  }

  $output = &drupal_static('metatag_panels');
  $static = drupal_static('metatag_panels');
  $context = $static['context'];
  $info = $static['info'];

  $handler = $context['handler'];

@@ -227,29 +244,14 @@ function metatag_panels_ctools_render_alter($info, $page, $context) {
      $tag_output = $metatag_instance->getElement($options);
      // Don't output the pager if that's all there is.
      if ($tag_output != $current_pager) {
        $output[$metatag] = $tag_output;
        $metatags[$metatag] = $tag_output;
      }
    }
  }

  // Give third-parties the opportunity to alter the metatag for a given
  // instance.
  drupal_alter('metatag_metatags_view', $output, $options['instance']);
}

/**
 * Implements hook_page_build().
 *
 * @see metatag_panels_ctools_render_alter()
 */
function metatag_panels_page_build(&$page) {
  // By default do not add meta tags to admin pages. To enable meta tags on
  // admin pages set the 'metatag_tag_admin_pages' variable to TRUE.
  if (path_is_admin(current_path()) && !variable_get('metatag_tag_admin_pages', FALSE)) {
    return;
  }

  $metatags = drupal_static('metatag_panels');
  drupal_alter('metatag_metatags_view', $metatags, $options['instance']);

  if (!empty($metatags)) {
    // The page region can be changed.