0

I would like to build a custom breadcrumb based on node relation from entity reference. For example there is a book node that has menu hierarchy:

Book
|-chapter 1
|--sub chapter 1.1
|---sub sub chapter 1.1.1
|----#Node with different content type and not included/displayed on Book
      Navigation

The Page Node (sub sub chapter 1.1.1) has entity reference relation with node biblio (for ex)

What I want is when I access biblio then the breadcrumb is displayed like the above tree.

Possible solution: Write a code using nexus theme on template.php on function:

function nexus_breadcrumb($variables) {

  //$breadcrumb = $variables['breadcrumb'];
  //$node = $variables['node'];

  if ($node->type == 'biblio'){
   // pseudo code start
   // get 'book' node that point to biblio
   // get menu tree from the book node
   // construct the menu tree and assign it to $breadcrumb

   // this is I still not know how to code the section.
  }

  if (!empty($breadcrumb)) {
  // Use CSS to hide titile .element-invisible.
  $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
   // comment below line to hide current page to breadcrumb

  $output .= '<nav class="breadcrumb">' . implode(' » ', $breadcrumb) .   
   '</nav>';
   return $output;
  } 
}

Any help will do. Thank you.

1
  • I was going to suggest Crumbs for this, but now I'm not even sure it fully supports book module.. I think it does if you enable menu.hierarchy.* wildcard. The book menus will not show up as crumbs plugins, but it is ok if the menu.hierarchy.* wildcard is enabled. Then for the entityreference part you can enable one of the entityreference plugins. And don't be afraid of the UI. --- I will make this a real answer if someone can confirm that it works.
    – donquixote
    Sep 30, 2015 at 0:02

1 Answer 1

0

Menu Breadcrumb

  • Append the page title to the breadcrumb (either as a clickable url or not)
  • Hide the breadcrumb if it only contains the link to the front page.
  • Generate the breadcrumb from the URL structure if content does not belong to a menu (7.x-1.6 and older only)

For more details click here

Custom Breadcrumbs

Many new features have been added including support for Views, Panels, Taxonomy vocabularies and terms, paths, and a simple API that allows contributed modules to enable custom breadcrumbs for module pages and theme templates. These are implemented using optional, independent submodules that depend on the main Custom Breadcrumbs module.

In addition to breadcrumb visibility, this version provides an option permitting PHP code snippets to be used in forming the breadcrumb titles and paths. Multiple languages are also supported.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.