3

I'm using Path Breadcrumbs module for displaying breadcrumbs on particular pages.

Is there a way to set breadcrumbs not to display by default for ANY page and enable only particular ones using rules created with Path Breadcrumbs module?

In module there's an option to disable breadcrumbs by creating a rule for each URL pattern and setting breadcrumb and title to "" but how can I trigger rule for ANY drupal URL - nodes, taxonomy, views, panel pages etc. And then make rules only for those URLs which really need breadcrumbs to be displayed?

5 Answers 5

4

There is a patch for the Path Breadcrumbs module that adds a setting to disable other breadcrumbs: https://www.drupal.org/node/2483091

The patch allows an easy one click disabling of other breadcrumbs.

Here is a screenshot of the setting on the patch breadcrumbs settings page (admin/structure/path-breadcrumbs/settings) as it is in the current version of the patch: enter image description here

2
+100

I'm not using 'path breadcrumbs' module but I did the same thing on Drupal original breadcrumbs. Hope following simple code will inspire you.

function MY_THEME_preprocess_page(&$variables) {
  // List nids allow breadcrumbs.
  $nids_show_breadcrumbs = array(2, 4, 5, 6, 8);

  if (!in_array($variables['node']->nid, $nids_show_breadcrumbs)) {
    // Remove breadcrumb for all node not in our list.
    $variables['breadcrumb'] = '';
  }
}

This is an example of how to use this technique to stop breadcrumbs on all pages not handled by the path breadcrumbs module:

function MY_THEME_preprocess_page(&$variables) {
  // Get path breadcrumbs for the current page.
  $path_breadcrumbs_data = path_breadcrumbs_load_variant(current_path());

  // If there are no path breadcrumbs for this page then
  // don't show any breadcrumbs at all.
  if ($path_breadcrumbs_data === FALSE) {
    $variables['breadcrumb'] = '';
  }
}
3
  • That's a pretty good solution in general. Ideally in the case of path breadcrumbs it would use the path_breadcrumbs_load_variant() function to determine whether or not there were any path breadcumbs for the given page. - api.drupal.psu.edu/api/drupal/…
    – rooby
    Commented May 12, 2015 at 7:03
  • Aside from the path breadcrumbs patch answer I think that in terms of the bounty this answer is the best of the current solutions although it would have been better if it incorporated the feedback in my comment above, so I added that part.
    – rooby
    Commented May 13, 2015 at 6:26
  • Looks quite nice! Congrats!
    – Tim Yao
    Commented May 13, 2015 at 7:19
1
  1. select URL:path under selection rules.

  2. add it. and enter the listed pages on which you don't want to display breadcrumbs.

  3. or list only those pages on which you need breadcrumbs.

5
  • This could get a bit too complex to manage in some cases. For example if I have breadcrumbs on some node types but not others and some taxonomy term pages but not others and some views but not others I have to keep managing a bunch of other breadcrumb rules to stop breadcrumbs displaying on other pages.
    – rooby
    Commented May 6, 2015 at 0:27
  • You can solve your problem using custom breadcrumb module.[drupal.org/project/custom_breadcrumbs]
    – Viraj
    Commented May 6, 2015 at 3:56
  • True, that could be a workaround (there are a number of other alternative modules also), although it doesn't answer the question of doing it with path breadcrumbs.
    – rooby
    Commented May 6, 2015 at 4:48
  • Modules have their own set of functionality.As you are looking for applying it on pages,taxonomy,nodes and panes and etc. the suggested module have those functionality. Or else. you can add custom module which will list out all the pages,nodes and taxonomy with checkboxes and you can put like if check box is check then n then breadcrumb should be visible on that page.
    – Viraj
    Commented May 6, 2015 at 4:53
  • Yes. As you suggested, this patch can solve problem.
    – Viraj
    Commented May 6, 2015 at 4:57
0

The easiest way I know is to use the CSS "display: none;". Each content type page has their own body class. For example, the basic page content type has "body.node-type-page" or any custom content type "body.node-type-customcontenttypename".

You will need something like this in your CSS file(replace "customcontenttypename" with your custom content type name).

body.node-type-customcontenttypename #breadcrumb {
display: none;
}

Another option is to use the Custom Breadcrumbs, as Viraj_T mentioned. This module allow you to show breadcrumbs based on node type and or Vocabularies.

1
  • While it is a valid option to hide the breadcrumbs I would only recommend hiding something with CSS as a last resort when there are no other options (or you need it fixed in the next 5 minutes, in which case it might be a good temporary solution). There is generally always another option. For example, making the markup not print via the template.php or page.tpl.php is preferable to hiding with CSS.
    – rooby
    Commented May 11, 2015 at 23:28
0

watch and learn Drupal 7 Path Breadcrumbs Module - Daily Dose of Drupal Episode 36

1
  • Can you give a brief outline of the contents of the video? Answers that are just a link to somewhere else are discouraged on stack overflow.
    – rooby
    Commented May 11, 2015 at 23:27

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.