You are here

function print_link in Printer, email and PDF versions 5.2

Same name and namespace in other branches
  1. 5.4 print.module \print_link()
  2. 5 print.module \print_link()
  3. 5.3 print.module \print_link()
  4. 6 print.module \print_link()
  5. 5.x print.module \print_link()

Implementation of hook_link().

File

./print.module, line 51
Display printer-friendly versions of Drupal pages

Code

function print_link($type, $node = NULL, $teaser = FALSE) {
  $print_settings = variable_get('print_settings', print_settings_default());

  // No link is shown for several motives...
  if (!$teaser && $node->type != 'book' && !$node->parent && $print_settings['show_link'] && user_access('access print') && ($type == 'comment' && variable_get('print_display_comment', '0') || $type == 'node' && variable_get('print_display_' . $node->type, '1'))) {
    $links = array();
    $format = print_format_link();
    if ($type == 'comment') {
      $query = "comment={$node->cid}";
    }
    $links['print'] = array(
      'href' => PRINT_PATH . "/" . $node->nid,
      'title' => $format['text'],
      'attributes' => $format['attributes'],
      'query' => $query,
    );
    return $links;
  }
  else {
    return;
  }
}