function page_title_get_title in Page Title 7
Same name and namespace in other branches
- 8.2 page_title.module \page_title_get_title()
- 5.2 page_title.module \page_title_get_title()
- 6.2 page_title.module \page_title_get_title()
- 6 page_title.module \page_title_get_title()
- 7.2 page_title.module \page_title_get_title()
Simple wrapper function to get the currently set title for a page
Return value
string the title for the current page
1 call to page_title_get_title()
- page_title_tokens in ./
page_title.module - Implement hook_token_values().
File
- ./
page_title.module, line 355 - Enhanced control over the page title (in the head tag).
Code
function page_title_get_title() {
// If we're looking at a node or a comment on a node, get the node object from the menu system.
if (arg(0) == 'node' && is_numeric(arg(1)) || arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2)) && module_exists('comment')) {
$node = menu_get_object();
// If the node has a custom page title and the node type is configured to have a custom page title (ie, it's not a leftover from a previous setting), then use it.
if (!empty($node->page_title) && variable_get('page_title_type_' . $node->type . '_showfield', 0)) {
$title = check_plain(strip_tags($node->page_title));
}
}
elseif (($user = menu_get_object('user_uid_optional')) || ($user = menu_get_object('user'))) {
if (variable_get('page_title_user_showfield', 0) && ($user_title = page_title_load_title($user->uid, 'user'))) {
$title = check_plain(strip_tags($user_title));
}
}
elseif (module_exists('taxonomy') && ($term = menu_get_object('taxonomy_term', 2))) {
if (variable_get('page_title_vocab_' . $term->vid . '_showfield', 0) && ($term_title = page_title_load_title($term->tid, 'term'))) {
$title = check_plain(strip_tags($term_title));
}
}
// If nothing above set a title, give the legacy function a chance to act
if (empty($title)) {
$title = check_plain(strip_tags(page_title_set_title()));
}
// If we still have no title, fall back to the title provided by Drupal Core
if (empty($title)) {
$title = drupal_get_title();
}
// Give other modules the oppertunity to use hook_page_title_alter().
drupal_alter('page_title', $title);
// Return the title
return $title;
}