function _print_get_title in Printer, email and PDF versions 7
Same name and namespace in other branches
- 5.4 print.module \_print_get_title()
- 6 print.module \_print_get_title()
- 7.2 print.module \_print_get_title()
- 5.x print.module \_print_get_title()
Auxiliary function to discover a given page's title
Parameters
$path: path of the page being identified
Return value
string with the page's title
4 calls to _print_get_title()
- print_block_view in ./
print.module - Implements hook_block_view().
- print_mail_block_view in print_mail/
print_mail.module - Implements hook_block_view().
- print_mail_form in print_mail/
print_mail.inc - Menu callback for the send by email form.
- print_pdf_block_view in print_pdf/
print_pdf.module - Implements hook_block_view().
File
- ./
print.module, line 565 - Displays Printer-friendly versions of Drupal pages.
Code
function _print_get_title($path) {
$path = drupal_get_normal_path($path);
$nid = preg_replace('!^node/!', '', $path);
if (ctype_digit($nid)) {
return db_query("SELECT title FROM {node} WHERE nid = :nid", array(
':nid' => $nid,
))
->fetchField();
}
else {
// Not a node, try to get title from the menu system
$menu_item = menu_get_item($path);
if (!empty($menu_item['title'])) {
return $menu_item['title'];
}
elseif (drupal_substr($menu_item['page_callback'], 0, 6) == 'views_') {
// It's a view, load the view to have access to the title
$view = views_get_view($menu_item['page_arguments']['0']);
return $view
->get_title();
}
else {
return NULL;
}
}
}