More complete breadcrumbs for Ubercart checkout
by Dylan Tack, Web Developer
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
Posted by peach - all drupal themes on . [Reply]
seems like a great idea, I'll try it out and see if it plays nicely with the checkout workflow
Thanks, I'll give it a whirl.
Posted by Anonymous on . [Reply]
Thanks, I'll give it a whirl.
Thanks for this, it worked a
Posted by Brisbane Web Design on . [Reply]
Thanks for this, it worked a treat and solved a massive headache with Ubercart
Add new comment