Based on simple example.
decorate__admin_build_views_export__()
How I can remove the link from the last element?

CommentFileSizeAuthor
#8 crumbs-919166.patch2.61 KBkenorb
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

donquixote’s picture

Zen-based themes contain a setting that allows to configure the display of the last element.
You could also write your own implementation of theme_breadcrumb to do the same.

I am quite undecided if I should implement any of this in crumbs itself. I don't want to conflict with themes.
Maybe decorateTrail would be a good place?
I don't think the function you mention should do the job, because at that moment you don't know if you are dealing with the last item or not.

Do you always want the last item to be not a link, or just in specific cases?

kenorb’s picture

Currently I don't need it, but consider to implement that for specific cases.

kenorb’s picture

Priority: Normal » Minor
kenorb’s picture

Priority: Minor » Major

Yes, I need this.
This will do workaround for: #920510: Support $_GET parameters for search functionality.

kenorb’s picture

Probably this could be done by pre-process function before the rendering. I'll have a look.

To do this, I need following solutions or the right directions:

1.
New property in $item, i.e.: $item->link (bool).
Then in the class you can specify:

$item->link = FALSE;

to disable the link (by default: TRUE).

2.
How I can determine inside the class on which element currently I am.
I.e.:
doc_search/all/1234?s=English
on: 'doc_search/all' - 2nd crumb of total 3
Or in other words, if you do: '$item->link = FALSE;' in current class, how do I know which element it's in the rendered form?
Then I'd be able to remove the link tags from rendered breadcrumb based on position and settings programatically.

kenorb’s picture

No, it's even simpler.

function crumbs_build_breadcrumb($trail) {
  $breadcrumb = array();
  foreach ($trail as $path => $item) {
    $breadcrumb[] = $item->link();
  }
  return $breadcrumb;
}

Where $item->link(); returns the link.
Lets create method $item->plain(); when specified crumb has $item->link = FALSE;?

kenorb’s picture

Status: Active » Needs review
FileSize
2.61 KB

Tested with following method:

  function decorate__doc_search_all($path, $item) {
    if ($path == 'doc_search/all') {
        $item->title = t('Search');
        $item->link = FALSE;
    } 
  }

'Search' item is not link anymore.

Fixes as well: #921786: Empty last "active" crumb when trying to remove the last element,
so link() returns NULL, if the title or path is empty.

I'm not sure about class names, you can change them as you prefer.

kenorb’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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