
More complete breadcrumbs for Ubercart checkout
By default, Ubercart sets the breadcrumb on the checkout page to simply "Home", which I personally find a bit odd. Because it calls drupal_set_breadcrumb()
late in the request cycle, it's not even possible to create menu links for use by the menu_breadcrumb or menutrails modules. Stranger still, the cart settings page offers a "Custom cart breadcrumb" text and URL option, but it's hard-coded to use a single link instead of a trail of links.
Here is a small snippet that will set the breadcrumbs to mimic the URL paths, for example:
Home › Cart › Checkout
/** * Implementation of hook_preprocess_page(). */ function mymodule_preprocess_page(&$variables) { /* * This section sets the breadcrumb on the cart pages hierarchically * according to the path elements. A preprocess function is * needed instead of drupal_set_breadcrumb() because Ubercart * aleady calls drupal_set_breadcrumb() with undesirable results, * which also thwarts the menutrails module. */ $menu = menu_get_item(); if (preg_match('/^cart($|\/)/', $menu['path'])) { $crumbs = array(l(t('Home'), '<front>')); $paths = array(); foreach ($menu['map'] as $arg) { $paths[] = $arg; $crumbs[] = l(ucfirst($arg), implode('/', $paths)); } $variables['breadcrumb'] = theme('breadcrumb', $crumbs); } }
Comments
seems like a great idea, I'll try it out and see if it plays nicely with the checkout workflow
Thu, 11/19/2009 - 16:52
Thanks, I'll give it a whirl.
Wed, 05/19/2010 - 03:56
Thanks for this, it worked a treat and solved a massive headache with Ubercart
Tue, 04/12/2011 - 21:05
The default checkout process in D7 UC3 still looks to work in the same way i.e. the checkout page is just Home.
I am new to this level of Drupal. So to implement the above, does this need to be placed into a module, or is this code for template.php?
Is there anything obvious that needs to change for D7 UC3?
Sat, 04/16/2011 - 17:57
Just a tip that stumped me for an hour or so. Make sure the weight of the module you put your code snippet into is heavier than uc_cart.
Thanks for the snippet!
Thu, 11/19/2009 - 09:16