blueedge Posted March 30, 2011 Share Posted March 30, 2011 I would like to use the breadcrumb code (includes/classes/breabcrumb.php) to create a link on the product page to advance the visitor up one category level. I know that this link already exists in the breadcrumb itself. However, I think that the breabcrumb is often overlooked by most visitors as a means to view similar products in the same category. HOME > CATEGORY > SUBCATEGORY > PRODUCT PAGE When a visitor enters the site on a product page, I want the visitors to quickly know that if product he/she is viewing is not what the visitor wants, there are other similar products in the same category (or subcategory) that just might be what he/she is searching for. By clicking on this "View Similar Products" link, the visitor would be taken one level up to the category (or subcategory) page. How do I modify the breadcrumb code to generate a link that is always one level up? I don't really know php. So, any help would be appreciated. Thanks. class breadcrumb { var $_trail; function breadcrumb() { $this->reset(); } function reset() { $this->_trail = array(); } function add($title, $link = '') { $this->_trail[] = array('title' => $title, 'link' => $link); } function trail($separator = ' - ') { $trail_string = ''; for ($i=0, $n=sizeof($this->_trail); $i<$n; $i++) { if (isset($this->_trail[$i]['link']) && tep_not_null($this->_trail[$i]['link'])) { $trail_string .= '<a href="' . $this->_trail[$i]['link'] . '" class="breadcrumb">' . $this->_trail[$i]['title'] . '</a>'; } else { $trail_string .= $this->_trail[$i]['title']; } if (($i+1) < $n) $trail_string .= $separator; } return $trail_string; } } Link to comment Share on other sites More sharing options...
blueedge Posted April 1, 2011 Author Share Posted April 1, 2011 FYI I was able to find a contribution that used the breadcrumb code to display the category name (http://www.oscommerce.com/community/contributions,1954). I simply modified that contribution's code to produce the URL for the category of the product being viewed. I now have a link that is one level up to the cateogry page. The link is displayed directly above the product image on the product page. So now if s visitor enters the site on a product page, and that particular product is not exactly what he/she wants, hopefully, he/she will stay on the site by clicking the "View Similar Items" link. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.