function print_node_view_alter in Printer, email and PDF versions 7
Implements hook_node_view_alter().
File
- ./
print.module, line 317 - Displays Printer-friendly versions of Drupal pages.
Code
function print_node_view_alter(&$build) {
if (isset($build['links']['book']['#links']['book_printer'])) {
$print_html_book_link = variable_get('print_html_book_link', PRINT_HTML_BOOK_LINK_DEFAULT);
if ($print_html_book_link) {
$print_html_link_pos = variable_get('print_html_link_pos', drupal_json_decode(PRINT_HTML_LINK_POS_DEFAULT));
if (!empty($print_html_link_pos['link'])) {
$format = theme('print_format_link');
switch ($print_html_book_link) {
case 1:
$path = $build['links']['book']['#links']['book_printer']['href'];
break;
case 2:
$print_html_link_use_alias = variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT);
$path = $print_html_link_use_alias && ($alias = drupal_lookup_path('alias', 'node/' . $build['#node']->nid)) ? $alias : $build['#node']->nid;
break;
}
$build['links']['book']['#links']['book_printer'] = array(
'href' => PRINT_PATH . '/' . $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
);
}
else {
unset($build['links']['book']['#links']['book_printer']);
}
}
}
}