In Drupal 7, hook_menu_breadcrumb_alter(&$active_trail, $item) lets you modify the breadcrumb by altering the $active_trail array, which Drupal uses to build the breadcrumb. When a page like reports/export/csv is being rendered, this hook gives you access to the trail, and you can append or replace items in it.
By using menu_get_item('reports'), you're pulling in the menu item definition for the reports page directly — including its title and path — and adding it to the breadcrumb trail. Since menu_get_item() returns the correct structure expected in $active_trail, there's no need to manually build the array. You then add the final breadcrumb (e.g., CSV Export) manually. Drupal takes your modified trail and uses it to render the breadcrumb links in order. This method ensures consistency and reuses existing menu definitions cleanly.
Source code viewer
function HOOK_menu_breadcrumb_alter(&$active_trail, $item) { if (current_path() == 'reports/export/csv') { $active_trail[] = menu_get_item('reports'); 'title' => 'CSV Export', 'href' => 'reports/export/csv', ); } }Programming Language: PHP