You are here

function _matomo_get_hierarchy_titles in Matomo Analytics 7.2

Same name and namespace in other branches
  1. 8 matomo.module \_matomo_get_hierarchy_titles()

Get the page titles trail for the current page.

Based on menu_get_active_breadcrumb().

Return value

array All page titles, including current page.

1 call to _matomo_get_hierarchy_titles()
matomo_page_alter in ./matomo.module
Implements hook_page_alter() to insert JavaScript to the appropriate scope/region of the page.

File

./matomo.module, line 691
Drupal Module: Matomo

Code

function _matomo_get_hierarchy_titles() {
  $titles = array();

  // No breadcrumb for the front page.
  if (drupal_is_front_page()) {
    return $titles;
  }
  $item = menu_get_item();
  if (!empty($item['access'])) {
    $active_trail = menu_get_active_trail();

    // Allow modules to alter the breadcrumb, if possible, as that is much
    // faster than rebuilding an entirely new active trail.
    drupal_alter('menu_breadcrumb', $active_trail, $item);

    // Remove the tab root (parent) if the current path links to its parent.
    // Normally, the tab root link is included in the breadcrumb, as soon as we
    // are on a local task or any other child link. However, if we are on a
    // default local task (e.g., node/%/view), then we do not want the tab root
    // link (e.g., node/%) to appear, as it would be identical to the current
    // page. Since this behavior also needs to work recursively (i.e., on
    // default local tasks of default local tasks), and since the last non-task
    // link in the trail is used as page title (see menu_get_active_title()),
    // this condition cannot be cleanly integrated into menu_get_active_trail().
    // menu_get_active_trail() already skips all links that link to their parent
    // (commonly MENU_DEFAULT_LOCAL_TASK). In order to also hide the parent link
    // itself, we always remove the last link in the trail, if the current
    // router item links to its parent.
    if (($item['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT) {
      array_pop($active_trail);
    }
    foreach ($active_trail as $parent) {
      $titles[] = $parent['title'];
    }
  }
  return $titles;
}