Use case:
A views page whose path is myview/1 (1 is an uid). The views path is actually myview/%, with an argument. I don't want to build a menu item for this view because it has no sense, as the path 'myview' (with no arg) is not allowed in this use case. So I don't set any menu settings for my view.
The view has a global title: "My view". The argument is set to not override the view's title (checkbox unchecked).

I expect the breadcrumb to be :
Home (link to front page) / My view (no link, title of the current page)

I actually get :
Home / 1

This is because the findTitle() method of the views plugin (coming from #1914718: Crumbs on Views with Arguments/Contextual Filters) does not handle the use case. I managed to get what I wanted by replacing this:

// Trigger the argument calculation by calling build_title().
    $view->build_title();

    // Check the last argument for a breadcrumb item title.
    $argument = $view->argument;
    while (!empty($argument)) {
      $last_arg = array_pop($argument);
      if (1
        && is_object($last_arg)
        && !$last_arg->is_exception()
        && isset($last_arg->argument)
      ) {
        if ($last_arg_title = $last_arg->get_title()) {
          // Use decode_entities() to undo duplicate check_plain().
          // See https://drupal.org/comment/7916895#comment-7916895
          return array("$view_name.$view_display_id" => decode_entities($last_arg_title));
        }
        break;
      }
    }

with this:

// Trigger the argument calculation by calling build_title().
    $view->build_title();

    // Check the last argument for a breadcrumb item title.
    $argument = $view->argument;
    while (!empty($argument)) {
      $last_arg = array_pop($argument);
      if (1
        && is_object($last_arg)
        && !$last_arg->is_exception()
        && isset($last_arg->argument)
        && !empty($last_arg->options['title_enable'])
      ) {
        if ($last_arg_title = $last_arg->get_title()) {
          // Use decode_entities() to undo duplicate check_plain().
          // See https://drupal.org/comment/7916895#comment-7916895
          return array("$view_name.$view_display_id" => decode_entities($last_arg_title));
        }
        break;
      }
    }
    if ($title = $view->get_title()) {
      return array($title);
    }

i.e. I added the condition !empty($last_arg->options['title_enable']) to check if the argument is set to override the default title, and a fallback to default to the view's global title.

CommentFileSizeAuthor
#1 crumbs-7.x-2.x-2235691-1-views.patch8.04 KBdonquixote
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

donquixote’s picture

Status: Active » Needs review
FileSize
8.04 KB

Total rewrite of the Views stuff.
Could you give it a try?

donquixote’s picture

donquixote’s picture

Status: Needs review » Fixed

Should be fixed in new release 7.x-2.0-beta14.
Please reopen if not.

donquixote’s picture

Sorry, I forgot to merge. So beta14 does NOT contain the fix.
7.x-2.0-beta16 should do it.

donquixote’s picture

And 7.x-2.0-beta17 ..

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.