Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Change product breadcrumb to name not model


Stryks

Recommended Posts

Well .. .that pretty much asks my question I suppose.

 

The breadcrumb navigation at the top od the page (home }} category 1 }} product 1) lists products by their model number, but I would like to show the product names instead if this is at all possible.

 

How would I make this change? Thanks

Link to comment
Share on other sites

Backup...Backup...Backup

In /includes/application_top.php:

FIND:

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

REPLACE WITH:

// add the products name to the breadcrumb trail
 if (isset($HTTP_GET_VARS['products_id'])) {
   $crumb_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . $languages_id . "'");
   if (tep_db_num_rows($crumb_query)) {
     $crumb = tep_db_fetch_array($crumb_query);
     $breadcrumb->add($crumb['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
   }
 }

Link to comment
Share on other sites

Is there an if statement that could be used to abreviate the product name if gets to many characters long? Id use this but some of my product names get so long it wraps along the header ...

Link to comment
Share on other sites

Is there an if statement that could be used to abreviate the product name if gets to many characters long? Id use this but some of my product names get so long it wraps along the header ...

I didn't know if there was anything like this built into osC so I just wrote a little function for it ...

 

Put this in catalog/includes/functions/general.php (right before the last ?>) and then you can use it in any file ...

 

    // Limit characters returned and add tail
   function short_bychars($text,$length=60,$tail=" ...") {
   $text = trim($text);
    $txtl = strlen($text);
    if($txtl > $length) {
      for($i=1;$text[$length-$i]!=" ";$i++) {
        if($i == $length) {
          return substr($text,0,$length) . $tail;
      }
    }
        $text = substr($text,0,$length-$i+1) . $tail;
    }
    return $text;
 }

 

Usage in this case would be short_bychars($crumb['products_name'], $length) where length is any number you choose. Optionally, you can add the 3rd parameter to change the tail on a case-by-case basis, or you can just change it in the function for all instances.

Link to comment
Share on other sites

How about changing the actual wording for some of the breadcrumbs - for instance I would rather say home than top. Have not been able to figure this one out yet.

Thanks!

bbw

Link to comment
Share on other sites

How about changing the actual wording for some of the breadcrumbs - for instance I would rather say home than top. Have not been able to figure this one out yet.

Thanks!

bbw

That's located at the top of /catalog/includes/languages/english.php :)

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 year later...
In /includes/application_top.php:

 

// add the products name to the breadcrumb trail
 if (isset($HTTP_GET_VARS['products_id'])) {
$crumb_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . $languages_id . "'");
if (tep_db_num_rows($crumb_query)) {
  $crumb = tep_db_fetch_array($crumb_query);
  $breadcrumb->add($crumb['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
}
 }

 

Whenever I browse my store...if I view the Manufacturers list of products and then select a product the breadcrumbs will display the manufacturer name - but if i take any other route (search, bestsellers, etc.) then the bread crumbs only show the product name.

 

How would the above code be altered so that everytime the breadcrumbs would display:

Top >> Catalog >> MANUFACTURER >> Product Name

 

Thanks!

Link to comment
Share on other sites

How would the above code be altered so that everytime the breadcrumbs would display:

Top >> Catalog >> MANUFACTURER >> Product Name

slight correction.... it actually shows the catagory in the breadcrumb as well - so the ideal modifcation would show the breadcrumbs as:

Top >> Catalog >> Catagory >> MANUFACTURER >> Product Name

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...