The following patch allow users to choose a more specific way to render the breadcrumbs for a page display.

Also make breadcrumbs a plugin so other modules can provide new ones.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Issue tags: +views 3.x roadmap

Adding a tag.

dagmar’s picture

Some cleanup. IMO I don't think it need much more changes.

dagmar’s picture

Status: Needs review » Needs work

Missing translatable support.

dagmar’s picture

Status: Needs work » Needs review
FileSize
17.64 KB

Added translatable support. Fixed some small issues with default values.

Custom breadcrumbs now don't merge with an existent breadcrumb, after all they are custom breadcrumbs.

Shadlington’s picture

Subscribing

Shadlington’s picture

I'm pleased to report that the patch works perfectly for me :)

Shadlington’s picture

-Deleted-

dagmar’s picture

After read this http://drupal.org/node/646284#comment-4381712 I think the easier way to include pluggable breadcrumbs is using another module.

So I'm attaching two different patches. The first one is an improved version of patch #4, that includes the ability to modify the link title, and provides a better ui.

The second patch only includes the necessary structure to make breadcrumbs pluggable. Is something similar to what we did for pluggable Exposed Forms. Less lines of code, less to review.

Of course It would be nice to see the first patch in, but I don't have any problems to maintain another module to provide custom breadcrumbs, however I need the structure patch in to do that.

Let me know what do you think.

dagmar’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
FileSize
15.71 KB

New patch, now for 7.x-3.x

This code has a less intuitive UI than #8 but doesn't need a custom function to translate the strings.

Two plugins are provided, 'default' and custom that allow users to create breadcrumbs with three parts: title, link and description for the link:

Each part of the breadcrumb is defined in one line. Each line should have a title and optionally a path and a description for the link to generate, i.e:

Home|***FRONT***|Go to front page
My content|content
You are here...

Will produce a breadcrumb like this:

Home > My content > You are here

dawehner’s picture

The patch is definitive great work.

Just in general i'm wondering whether this is in the scope of views. The module custom_breadcrumbs gives a very flexible way to configure breadcrumbs system wide. That's what people actually need, as they have breadcrumbs issues not only with views.

If that module even adds a display extender it would be capable of everything.

dagmar’s picture

Yes custom_breadcrumbs could do the job, as a custom module too.

However I'm thinking in three things at this moment.

1) Exportability (all the views stuff are into the view object)
2) Translations (allowing to translate all the part of the view using the new translation methods)
3) Access to arguments (I'm not sure if custom_breadcrumbs can do this at this moment)

Of course it is your decision, but something I have learn from views module is that allowing developers to create pluggings can make development of drupal sites much more powerful.

tim.plunkett’s picture

Triggering the testbot.

markwk’s picture

@dagmar: nice work! I tested it on the latest dev work in 7x.-3.x and it works nicely. I agree with your reasoning. I think the best solution would be to get a simple structural patch accepted and move development to a separate module.

I'm not familiar with Views coding to access the code itself. Have any views maintainers accessed this?

tim.plunkett’s picture

Assigned: Unassigned » dawehner

Assigning to @dawehner for feedback, I think #11 answers most of his questions.

Chris Matthews’s picture

Assigned: dawehner » Unassigned
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

The 7 year old patch in #9 does not apply to the latest views 7.x-3.x-dev and if still applicable needs a reroll.

Checking patch includes/plugins.inc...
error: while searching for:
        'handler' => 'views_plugin_query_default'
      ),
    ),
    'cache' => array(
      'parent' => array(
        'no ui' => TRUE,

error: patch failed: includes/plugins.inc:246
error: includes/plugins.inc: patch does not apply
Checking patch includes/view.inc...
error: while searching for:
   *   If true, use drupal_set_breadcrumb() to install the breadcrumb.
   */
  function get_breadcrumb($set = FALSE) {
    // Now that we've built the view, extract the breadcrumb.
    $base = TRUE;
    $breadcrumb = array();

    if (!empty($this->build_info['breadcrumb'])) {
      foreach ($this->build_info['breadcrumb'] as $path => $title) {
        // Check to see if the frontpage is in the breadcrumb trail; if it
        // is, we'll remove that from the actual breadcrumb later.
        if ($path == variable_get('site_frontpage', 'node')) {
          $base = FALSE;
          $title = t('Home');
        }
        if ($title) {
          $breadcrumb[] = l($title, $path, array('html' => true));
        }
      }

      if ($set) {
        if ($base) {
          $breadcrumb = array_merge(drupal_get_breadcrumb(), $breadcrumb);
        }
        drupal_set_breadcrumb($breadcrumb);
      }
    }
    return $breadcrumb;
  }

error: patch failed: includes/view.inc:1434
error: includes/view.inc: patch does not apply
Checking patch plugins/views_plugin_breadcrumb.inc...
Checking patch plugins/views_plugin_breadcrumb_custom.inc...
Checking patch plugins/views_plugin_breadcrumb_default.inc...
Checking patch plugins/views_plugin_display_page.inc...
Hunk #1 succeeded at 55 (offset 14 lines).
Hunk #2 succeeded at 331 (offset 39 lines).
Hunk #3 succeeded at 531 (offset 51 lines).
Hunk #4 succeeded at 639 (offset 59 lines).
Checking patch views.info...
Hunk #1 succeeded at 225 (offset 21 lines).
Andrew Answer’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
14.84 KB

Patch rerolled.