You are here

function comment_page_title_pattern_alter in Page Title 8.2

Same name and namespace in other branches
  1. 6.2 modules/comment.page_title.inc \comment_page_title_pattern_alter()
  2. 7.2 modules/comment.page_title.inc \comment_page_title_pattern_alter()

Implements hook_page_title_pattern_alter().

File

modules/comment.page_title.inc, line 36
Comment implementations of the page title hooks

Code

function comment_page_title_pattern_alter(&$pattern, &$types) {
  $menu_item = menu_get_item();

  // Comment reply page.
  if (!strncmp($menu_item['path'], 'comment/reply/%', 15) && ($node = menu_get_object('node', 2))) {

    // The node ID position is in arg 2.
    $types['node'] = $node;

    // If the node has any taxonomy, grab the first time and pass it over to be
    // passed as a token.
    // TODO: Handle multiple terms? Only pass specific terms per content type?
    if (!empty($types['node']->taxonomy)) {
      reset($types['node']->taxonomy);
      $types['taxonomy'] = current($types['node']->taxonomy);
    }
    if (is_numeric(arg(3)) && ($comment = menu_get_object('comment', 3))) {

      // Comment Reply...
      $types['comment'] = $comment;
      $pattern = variable_get('page_title_comment_child_reply', '');
    }
    else {

      // Reply to node...
      $pattern = variable_get('page_title_comment_reply', '');
    }
  }
}