Question

On my Drupal7 have a views (results) width a exposed filter for list the nodes.

When click on a node then display a breadcrumb

ex.

Home >> results >> node-title

Thats good!

But i will make the breadcrumb 'results' a backlink.

When input ex. t then the url is:

http://www.site.com/results?title=t

I try the above url as variabele in the 'results' breadcrumb.

I hope you understand this.

Is this possible with a php snippet in custom breadcrumbs?

Was it helpful?

Solution

Yes this is possible :)

The tricky part here is having your code "remember" what the query was from the list of nodes. One option would be to add a $_GET parameter to all of the node links.

For clarity:

If you are on

http://www.site.com/results?title=t

A link to a given node on that list of results would be:

http://www.site.com/node/56?title=t

This can be done in views by modifying the output of the link. Shouldn't be too hard.

Then, to modify the breadcrumbs you need to add a function like this to template.php

function THEME_NAME_breadcrumb($variables) {
  $breadcrumb = $variables['breadcrumb'];

  // check to ensure this is the one you want to alter
  // Custom rebuild process of breadcrumb with custom links.
  if ($breadcrumb[1] == 'your_breadcrumb_id') {

    // Keeping the trail/current page as non linked
    $links[1] = l(t('results'), 'results', array('query' => array('title' => $_GET['title'])));
    drupal_set_breadcrumb($links);
  }
}

(Check my code for syntax, its untested)

Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top