Breadcrumbs are a great way to navigate through any ecommerce site. Magento’s default theme has breadcrumbs (with microformats!) on product and category pages. This means that there is little work for you to do when setting up a site – as these are all autogenerated for you.
Missing Breadcrumbs
One thing missing however, is that Magento doesn’t have them on any page within the accounts section.
Luckily though, Magento’s extensible system offers an easy way to add breadcrumbs to the account area using a local.xml file. To complicate matters slightly, the account area does have multiple modules linked in to it, so we’ll need to add a number of layout updates in our local.xml file in order to cover the whole customer area.
Layout files resides under /app/design/frontend/your_interface/your_theme/layout/.
Steps to create the missing Breadcrumbs
Now that we know how to add breadcrumbs to the accounts area, we’re going to go ahead and create a local.xml file for our theme. Create the following file: /app/design/frontend/your_interface/your_theme/layout/local.xml – of course, if you already have one, we can simply add in the required information to the existing file.
An empty local.xml file will look something like this. it is, after all, an XML document:
< ?xml version="1.0"?>
When thinking about the customer account area, we;re probably going to want to include some default breadcrumb elements on every page. Namely: “Home”, and “My Account”. So, we can add a generic rule in to allow us to do this. To do this, we use the customer_account namespace.
Home
Home
/
My Account
My Account
/customer/account/
If you go and refresh your cache, and log in to your account, you should now have a default breadcrumb on all of your customer account pages with “Home / My Account” displayed.
We can now go through and add the additional breadcrumbs for:
- Dashboard
- Address Book
- Add/Edit Address
- Account Information
- Product Review
- My Tags
- My Downloadable Items
- Wishlist
- Newsletter Management
- Order History
- Individual Order Item in History
We’re going to follow the exact same process, adding the reference, and then adding the breadcrumbs for each section. It’s really only the namespace that’s going to change.
Dashboard
Dashboard
Dashboard
Address Book
Address Book
Address Book
Add/Edit Address
Address Book
Address Book
/customer/address/
Add/Edit Address
Add/Edit Address
Account Information
Account Information
Account Information
Product Review
My Product Reviews
My Product Reviews
My Tags
My Tags
My Tags
My Downloadable Items
Downloadable Products
Downloadable Products
Wishlist
My Wishlist
My Wishlist
Newsletter Management
Newsletter Manage
Newsletter Manage
Order History
My Orders
My Orders
Individual Order Item in History
My Orders
My Orders
/sales/order/history/
Order View
Order View
And there we have it. If you combine all of these into a single local.xml document, you will have breadcrumbs throughout the whole customer account section.
Image Credit: Jörn Guy Süß
Comment or tweet @douglasradburn