Wednesday, December 29, 2010

Drupal breadcrumb html over-ride.

If you are trying to do something freaky with your breadcrumbs (that you can't find a way to implement programatically using the administrative interface or a custom module) you can make use the Drupal templating system in order to place a custom breadcrumb on any single node, formatted however you like in HTML.

To do this, the first thing you will need to get is the node id of the page you are trying to modify. To find the node id, navigate to the Content/List section. If you have trouble navigating to that section of the site, simply put this path at the end of your domain name: /admin/content/node/overview

You will see your particular node in the list of content displayed. To the right of your page/node, hover your mouse over the "edit" link. The link will display the node id in the form of /node/18/edit?destination=admin/content/node/overview (where the node id in this case is 18).

Now to create a custom node template to display your html breadcrumb.

With a local copy of your drupal theme, find the current template that is used for your node. Look for files with the .tpl extension. If your node is a page, open the page.tpl file for editing. Don't save over it. You'll be saving it to a different filename after you edit it.

Inside the .tpl file, locate the string to text that reads:
Delete it and replace it with your HTML.

To use this template file only for the node that you wish it displayed on, simply save as so the filename reads (in this case) "page-node-18.tpl". Upload it to your current theme's directory.

Your theme might put these files in a templates subfolder so take a look around and test to be sure.

1 comment:

  1. I think there's something missing here:



    Inside the .tpl file, locate the string to text that reads:
    Delete it and replace it with your HTML.

    ReplyDelete