function printfriendly_create_button in PrintFriendly & PDF 8
Same name and namespace in other branches
- 8.3 printfriendly.module \printfriendly_create_button()
- 8.2 printfriendly.module \printfriendly_create_button()
- 7.5 printfriendly.module \printfriendly_create_button()
- 7 printfriendly.module \printfriendly_create_button()
- 7.2 printfriendly.module \printfriendly_create_button()
- 7.3 printfriendly.module \printfriendly_create_button()
- 7.4 printfriendly.module \printfriendly_create_button()
2 calls to printfriendly_create_button()
- PrintfriendlyBlock::build in src/
Plugin/ Block/ PrintfriendlyBlock.php - Builds and returns the renderable array for this block plugin.
- printfriendly_node_view in ./
printfriendly.module
File
- ./
printfriendly.module, line 88 - Adds PrintFriendly button to chosen node types and provides a block.
Code
function printfriendly_create_button($url = NULL, $popup = TRUE) {
global $base_url;
$config = \Drupal::config('printfriendly.settings');
$current_path = \Drupal::service('path.current')
->getPath();
$query_string = \Drupal::request()->query
->all();
if (!$url) {
$url = Url::fromURI($base_url . $current_path, array(
'query' => $query_string,
));
$full_path = $url
->toString();
}
else {
$url = Url::fromURI($base_url . $url, array(
'query' => $query_string,
));
$full_path = $url
->toString();
}
$image = drupal_get_path('module', 'printfriendly') . '/images/' . $config
->get('printfriendly_image', 'button-print-grnw20.png');
if ($popup) {
return array(
'#type' => 'link',
'#markup' => Markup::create('<a href="http://www.printfriendly.com/print?url=' . $full_path . '" class="printfriendly" onclick="window.print(); return false;" title="Printer Friendly and PDF"><img src="' . file_create_url($image) . '" alt="Printer Friendly and PDF" /></a>'),
);
}
else {
return array(
'#markup' => Markup::create('<a href="http://www.printfriendly.com/print?url=' . $full_path . '" class="printfriendly" title="Printer Friendly and PDF"><img src="' . file_create_url($image) . '" alt="Printer Friendly and PDF" /></a>'),
);
}
}