You are here

function forward_page_attachments in Forward 8

Same name and namespace in other branches
  1. 8.3 forward.module \forward_page_attachments()
  2. 8.2 forward.module \forward_page_attachments()
  3. 4.x forward.module \forward_page_attachments()
  4. 4.0.x forward.module \forward_page_attachments()

Implements hook_page_attachments().

File

./forward.module, line 18
Allows forwarding of entities by email.

Code

function forward_page_attachments(array &$page) {
  if (\Drupal::routeMatch()
    ->getRouteName() == 'forward.form') {
    $settings = \Drupal::config('forward.settings')
      ->get();
    if ($settings['forward_interface_type'] == 'link') {

      // Tell SEO to ignore this page on request
      if ($settings['forward_link_noindex']) {
        $element = array(
          '#type' => 'html_tag',
          '#tag' => 'meta',
          '#attributes' => array(
            'name' => 'robots',
            'content' => 'noindex, nofollow',
          ),
        );
        $page['#attached']['html_head'][] = [
          $element,
          'forward_meta_noindex',
        ];
      }
    }
  }
}