Title hooks overriding default behavior (segment and page) would be very useful sometimes.
Here is a patch to provide segment hooks and code snippet to get titles of pages, which are created or overrided by Views.
E.g. title depends on contextual filter.

function MYMODULE_easy_breadcrumb_segment_title($normal_path, $valid_path, $segment_text) {
  $overrides = array();
  if (!$valid_path) return $overrides;
  $router_item = menu_get_item($normal_path);
  if ($router_item && $router_item['page_callback'] == 'views_page') {
    $view_name = array_shift($router_item['page_arguments']);
    $display = array_shift($router_item['page_arguments']); 
    $view = views_get_view($view_name);
    if ($view) {
      $view->set_display($display);
      $view->pre_execute($router_item['page_arguments']);
      $view->init_query();
      $view->init_handlers();
      $view->_build_arguments();
      $title = $view->get_title();
    }
  }
  if (isset($title) && $title) $overrides[$normal_path] = $title;
  return $overrides;
}

function MYMODULE_easy_breadcrumb_segment_title_alter(&$title, $context) {
  // another hook for example
  // $title already contains the right value
}
CommentFileSizeAuthor
title-hooks.patch1.43 KBplayer259

Comments

player259’s picture

Issue summary: View changes
sonemonu’s picture

Priority: Normal » Minor
Status: Needs review » Closed (won't fix)

Such title's overrides must be done by your custom modules. This module will then use such titles for generating breadcrumbs.

This is not a responsability of this module.

greg boggs’s picture

To expand on what Sonemonu is stating here, for those not familiar with Drupal...

Easy Breadcrumb is great because it will use the title correctly and there are many, many methods for changing titles in Drupal. If you use any hook to alter a title, Easy Breadcrumb should correctly use any title you've set in any module or hook you've set it with.

liezie_d’s picture

@player259
thanks for providing this code!
i was using hook_menu_breadcrumb_alter to try to overwrite the breadcrumb in my own module but this was not working.
with this code i'll be able to change my install of easy breadcrumb and add this functionality myself. not ideal, as i wont be able to upgrade anymore, but choices have to be made.
Thanks again!

@module maintainers
my module has several paths where the URL is a bad base for building the breadcrumb path.
on those pages i need to overwrite the default working of EB and create a better (read: more userfriendly) breadcrumb path
a hook is just what i need. And OP provided.