Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Precise and Accurate Bread Crumb Trail


spoofy

Recommended Posts

Problem-

Product:

Running Shoes

 

In Categories:

Red Shoes

Blue Shoes

 

The issue occurs when you create a product in let's say Red Shoes and link it in Blue Shoes. When a customer is browsing the category Blue Shoes and goes to the product Running Shoes, the bread crumb trail and the menu on the left hand side is highlighted as Red Shoes.

 

This is because the product resides in the category of Red Shoes. Accurate to an extent, but the idea of bread crumb is to show the user how he/she got there.

 

Solution-

With this small addition which checks for referers will work 97% of the time based on some stats I picked up on some webmaster blogs and forums. For the remainder 3% it won't work but you have nothing to loose.

 

Please note that this modification only works if you are using the Ultimate SEO URLs by FWR Media. It is compatible with the old version USU5 and the new one USU5 Pro.

 

 

open /catalog/includes/functions/general.php

 

find:

 

function tep_get_product_path($products_id) {

 

immediately after that, paste the following code:

 

// we will check to see if a referer is available.
   // if a referer is available we will explode it to ensure that any parameters such as ?action=blah are not used
   if (isset($_SERVER['HTTP_REFERER'])) {
       $referer = $_SERVER['HTTP_REFERER'];
       if (stristr($referer, '.html?')) { list($referer, $query_string) = explode("?", $referer); }
   }
   else {
       $referer = 'Referer Not Available';
   }
   // we will check to see if the referer matches with our url
   // we will also check to see if the url has -c-2.html or -c-2_1.html (used for defining categories)
   // if it matches, then we will extract the value for the category path and assign it to $cPath
   if ((stristr($referer, HTTP_SERVER . DIR_WS_HTTP_CATALOG)) && (stristr($referer, '-c-')) && (stristr($referer, '.html')) && (preg_match('/-c-(\d+(?:_\d+)?)\.html$/i',$referer))) {
           preg_match('/-c-(\d+(?:_\d+)?)\.html$/i',$referer, $matches);
           if (isset($matches[1])) { $cPath = $matches[1];}
           else { }
   }
   else {

 

 

About 14 to 18 lines below that you will find

 

   }
   return $cPath;
 }

 

Replace that with:

 

     }
   }
   return $cPath;
 }

 

And voila! you are done.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...