page_title_get_title

Versions
5 – 6
page_title_get_title()
7
page_title_get_title($raw = FALSE)

Simple wrapper function to get the currently set title for a page

Return value

string the title for the current page

Code

contrib/page_title/page_title.module, line 322

<?php
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 = $node->page_title;
    }
  }
  // If we're looking at either a user profile page or a users blog page, get the user title
  elseif ((arg(0) == 'user' || arg(0) == 'blog') && is_numeric(arg(1))) {
    if (variable_get('page_title_user_showfield', 0) && ($user_title = page_title_load_title(arg(1), 'user'))) {
      $title = $user_title;
    }
  }
  // If we're looking at a taxonomy term page, get the term title
  elseif (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) && module_exists('taxonomy')) {
    $term = taxonomy_get_term(arg(2));
    if (variable_get('page_title_vocab_'. $term->vid .'_showfield', 0) && ($term_title = page_title_load_title($term->tid, 'term'))) {
      $title = $term_title;
    }
  }
  // If we're looking at a forum page determin if is a container/forum or the forum root
  elseif (arg(0) == 'forum' && module_exists('forum')) {
    // If there is a number then its a container or forum
    if (is_numeric(arg(1))) {
      $term = taxonomy_get_term(arg(1));
      if (variable_get('page_title_vocab_'. $term->vid .'_showfield', 0) && ($term_title = page_title_load_title($term->tid, 'term'))) {
        $title = $term_title;
      }
    }
    // If not then it's the forum root.
    else {
      $title = variable_get('page_title_forum_root_title', '');
    }
  }

  // If nothing above set a title, give the legacy function a chance to act
  if (empty($title)) {
    $title = 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 in a safe form (any tags removed (such as emphasised or strong tags) and eny entiied encoded)
  return filter_xss($title, array());
}
?>