4.6.x menu.inc menu_get_active_title()
4.7.x menu.inc menu_get_active_title()
5.x menu.inc menu_get_active_title()
6.x menu.inc menu_get_active_title()
7.x menu.inc menu_get_active_title()

Get the title of the current page, as determined by the active trail.

Related topics

1 call to menu_get_active_title()
drupal_get_title in includes/path.inc
Get the title of the current page, for display on the page and in the title bar.

File

includes/menu.inc, line 1630
API for the Drupal menu system.

Code

function menu_get_active_title() {
  $active_trail = menu_get_active_trail();
  foreach (array_reverse($active_trail) as $item) {
    if (!(bool) ($item['type'] & MENU_IS_LOCAL_TASK)) {
      return $item['title'];
    }
  }
}

Comments

Dave Reid’s picture

Beware: the return value of this function is interpreted as HTML. If you are printing the result of this function in your code or theme, you must escape them with check_plain or use the correct placeholder in t(). If you don't, users can execute a cross site scripting attack against your site.

// Incorrect:
print menu_get_active_title();

// Correct:
print check_plain(menu_get_active_trail());
d.sandip59’s picture

I have used echo check_plain(menu_get_active_trail()); and it does not print anything.