Advertising sustains the DA. Ads are hidden for members. Join today

Custom Breadcrumbs: Customizing the breadcrumb trail

Last updated on
30 April 2025

As the name suggests, Custom Breadcrumbs allows you to create and modify your own breadcrumbs based on node type. After enabling the module, go to Administer > User management > Access control. Grant the "administer custom breadcrumbs" permission to the appropriate roles. Then go to Administer > Site building > Custom breadcrumbs. On this page you'll see the option to add a new custom breadcrumb.

Clicking on that link, you have the option to select the node type the breadcrumb will apply to.

Below that, there are two text fields: "Titles" and "Paths." When creating a breadcrumb, you're simply creating a link. In the custom breadcrumbs interface "Titles" describes the text of the breadcrumb while "Paths" describes the Drupal path the breadcrumb links to. So each line of the title field corresponds to the equivalent line of the paths field. Thus, you must have the same number of titles and paths.

To give a very simple example of how to use this module, let's say I have a blog on my web site called "Deep Thoughts." To create this, I use the Views module to create a page at /blog that displays all the node types "blog post." Whenever a user views a blog post I want the breadcrumb to show Home > Deep Thoughts instead of simply Home. To do this I would simply type "Deep Thoughts" in the titles field and "blog" in the paths field and save my breadcrumb. Then, the first item in the breadcrumb would say "Deep Thoughts" and link to the path "blog" (the location of views page that lists blog posts).

Working with Tokens

Using the Token module, the Custom Breadcrumbs module becomes much more flexible: breadcrumbs can be dynamic. So I could create a breadcrumb like Home > Deep Thoughts > [Month of Blog Post] [Year of Blog Post] Where "Deep Thoughts" links to my main blog page and "[Month of Blog Post] [Year of Blog Post]" links to a view that shows only blog posts from the month and year the blog post was created (e.g. June 2007). To do this, create a custom breadcrumb for the node type "blog":

Titles:
Deep Thoughts
[month] [yyyy]

Paths:
blog
blog/[mm]_[yyyy]

(where of course, blog/[mm]_[yyyy] is the path to the view of blog posts from that month and year).
So if I created a blog post today (June 13, 2007) my breadcrumb would show Home > Deep Thoughts > June 2007 and "June 2007" links to "blog/06_2007" which is a view of all blog posts from June 2007.

Note:

  • that Custom Breadcrumbs doesn't actually check to be sure that a particular path exists, so you'll have to check yourself to avoid 404 errors.
  • blank lines in path and title lists are not stripped, and so can mess up the configuration.

Breadcrumb Visibility

Users given 'use php in custom breadcrumbs' permission can include php code snippet that returns TRUE or FALSE to control whether or not the breadcrumb is displayed. Note that this code has access to the $node variable, and can check its type or any other property.

Other reasons that the breadcrumb might not display, or that a breadcrumb trail other than expected displays, is that modules can override the breadcrumb trail. The module that has the highest priority gets to set the trail. There is no UI for setting module priority - you have to manually edit the weight field in the system table. Find the custom_breadcrumb's existing weight and change it to something higher than the competing module. One module that can compete in this way is the Image module.

Be sure to check your configuration settings in admin/config/user-interface/custom-breadcrumbs. If you attempt to use a wildcard '*' in your path but do not enable that checkbox under Advanced Settings on this page, your breadcrumbs will not display.

Special Identifiers

Special identifiers are provided to achieve a special behavior:

The following identifiers can be used to achieve a special behavior. Identifiers should be added to the paths area in the following format: identifier|path.
For example: <pathauto>|[ogname-raw]

Identifier: <none> Behaviour: This will result in a plain text crumb. This identifier should not be used with the pipe (|) symbol.

Identifier: <pathauto> Behaviour: Cleans the given path using your pathauto replacement rules.

Unlinked Node titles

For anyone wondering how to add the current node's title to the end of the breadcrumb, without an ugly theme hack, I would like to chip in with my suggestion. By using this module, you can for example set the custom breadcrumbs like this.

Titles:
Deep Thoughts
[month] [yyyy]
[title]

Paths:
blog
blog/[mm]_[yyyy]
<none>

The <none> token isn't listed but it works just as well, making the breadcrumb item a plain text string.

It is suggested you apply proper CSS to differentiate the plain text from the links, so not to confuse the users and to make it more obvious that this list of links (breadcrumb) is a site map of sorts.

Help improve this page

Page status: Not set

You can: