function printfriendly_node_view in PrintFriendly & PDF 7.4
Same name and namespace in other branches
- 8.3 printfriendly.module \printfriendly_node_view()
- 8 printfriendly.module \printfriendly_node_view()
- 8.2 printfriendly.module \printfriendly_node_view()
- 7.5 printfriendly.module \printfriendly_node_view()
- 7 printfriendly.module \printfriendly_node_view()
- 7.2 printfriendly.module \printfriendly_node_view()
- 7.3 printfriendly.module \printfriendly_node_view()
Implements hook_node_view().
File
- ./
printfriendly.module, line 134 - Adds PrintFriendly button to chosen node types and provides a block.
Code
function printfriendly_node_view($node, $view_mode) {
if (in_array($view_mode, array_filter(variable_get('printfriendly_display', array(
'full',
))))) {
if (in_array($node->type, variable_get('printfriendly_types', array()), TRUE) && user_access('access printfriendly')) {
if ($view_mode == 'teaser') {
$block = printfriendly_create_button('node/' . $node->nid, FALSE);
}
else {
$block = printfriendly_create_button();
foreach ($block['#attached']['js'] as $key => $value) {
drupal_add_js($key, $value);
}
}
$links['printfriendly'] = array(
'title' => $block['#markup'],
'attributes' => array(
'class' => array(
'printfriendly-node',
$node->type,
),
),
'html' => TRUE,
);
$node->content['links']['printfriendly'] = array(
'#theme' => 'links',
'#links' => $links,
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
);
}
}
}