About Club osCommerce

Showcasing osCommerce - the good, the bad and the ugly!

StumbleUpon It! DIGG It!

osCommerce Breadcrumb Tips

Written By Gary on May 05 2008 ·

Breadcrumbs or breadcrumb trails are a navigation technique used in user interfaces. Its purpose is to give users a way to keep track of their location within programs or documents. The term is taken from the trail of breadcrumbs left by Hansel and Gretel in the popular fairytale.

In osCommerce, the breadcrumb is made up of;

Link to Domain Name > Link to Catalog Install > Link to Category > Link to Product Model

Which isn't too useful in my opinion.  In fact, I'd go further and say that Breadcrumbs are vurtually useless in almost all ecommerce shops - why have a breadrcumb when there is already a "category" menu and "back" button in a persons browser.

Many years ago, when I was part of a small design team, we actually had shoppers in the office watching how they used site.  As I recall, maybe 1 in 20 actually used the breadcrumb feature of a standard osCommerce installation.

Anyway, if you do have a Breadcrumb, here's a few tips

If you want to remove the link to your Domain Name, open up /includes/application_top.php and remove this line of code:

PHP:
  1. $breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);

If you simply want to change the word "Top", open up /includes/languages/english.php and change this line of code:

PHP:
  1. define('HEADER_TITLE_TOP', 'Top');

If you want to remove the link to your Catalog install, open up /includes/application_top.php and remove this line of code:

PHP:
  1. $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));

If you simply want to change the word "Home", open up /includes/languages/english.php and change this line of code:

PHP:
  1. define('HEADER_TITLE_CATALOG', 'Home');

If you do not use the "Product Model" field in your product specs, then you might as well use something else in the breadcrumb - I think that using Product Model is dumb anyway - it's hardly helpful to the customer...so open up /includes/application_top.php and find this:

PHP:
  1. // add the products model to the breadcrumb trail
  2. if (isset($HTTP_GET_VARS['products_id'])) {
  3. $model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
  4. if (tep_db_num_rows($model_query)) {
  5. $model = tep_db_fetch_array($model_query);
  6. $breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
  7. }
  8. }

and change it to this:

PHP:
  1. // add the products NAME to the breadcrumb trail
  2. if (isset($HTTP_GET_VARS['products_id'])) {
  3. $model_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
  4. if (tep_db_num_rows($model_query)) {
  5. $model = tep_db_fetch_array($model_query);
  6. $breadcrumb->add($model['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
  7. }
  8. }

If you want to change the "seperator" in your breadcrumb from > to something else, open up /includes/header.php and find this code:

PHP:
  1. $breadcrumb->trail(' » ')

and change it to whatever symbol you wish to use.  I think I'll use a forward slash, so I would change it to this:

PHP:
  1. $breadcrumb->trail(' / ')

If you don't want the breadcrumb at all, open up /includes/header.php and remove this portion of code:

PHP:
  1. <td class="headerNavigation">  <?php echo $breadcrumb->trail(' » '); ?></td>

There you have it, an intro to using the breadcrumb.  Nice and easy, ain't it?


Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive. Cheers!


4 Comments

  1. Thanks, what awesome tips! I used the one to add the product name in the breadcrumb navigation and it worked beautifully, thank you so much!

    Comment by Angel's Affordable Web Design — May 5, 2008 @ 10:44 pm


  2. Glad you found it useful :)

    Comment by Gary — May 6, 2008 @ 7:18 am


  3. I'm not sure if it's just me and my browser (using latest FF v3.0) but the code regarding the application_top.php file appears in my browser:

    $breadcrumb->add($model['pr… and it gives me error

    so I modified to

    $breadcrumb->add($model['pr…

    now it works just fine, thank you for this piece of code :)

    Comment by Tomee80 — September 12, 2008 @ 9:14 pm


  4. here is the image how it appears in my browser:

    http://img527.imageshack.us/img527/3236/erroriu2.gif

    Cheers,
    Tomee

    Comment by Tomee80 — September 12, 2008 @ 9:22 pm


Leave a comment

RSS feed for comments on this post · TrackBack URL

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!