Forums / General Questions / Remove product from Bread Crumb Trail

Remove product from Bread Crumb Trail

Locked

Views: 4,088

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
13 May 2006, 3:36 AM
#1
magicpants avatar

magicpants

Zen Follower

Join Date:
Aug 2005
Posts:
314
Plugin Contributions:
0

Remove product from Bread Crumb Trail

How can one remove the product from the bread crumb trail, when viewing a product info page? I have long product names, so the bread crumb is wrapping -- plus the product name is displayed in the page title, right under the trail anyway.

I looked through classes/breadcrumb.php but couldn't work it through.

Currently using ZEN CART v. 1.3.6

13 May 2006, 4:34 AM
#2
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Remove product from Bread Crumb Trail

I use this code

<!-- bof  breadcrumb -->
<?php if (DEFINE_BREADCRUMB_STATUS == '1' && ($current_page!='index' || (int)$cPath>0 )) { ?>    <div id="navBreadCrumb"><?php echo $breadcrumb->trail(BREAD_CRUMBS_SEPARATOR); ?></div>
<?php } ?>
<!-- eof breadcrumb -->

tpl_main_page.php to keep the breadcrumb from showing on my main page.

I suppose you could modify it to include the product info page.

NOTE: We are sorry that Clyde is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

13 May 2006, 10:02 AM
#3
magicpants avatar

magicpants

Zen Follower

Join Date:
Aug 2005
Posts:
314
Plugin Contributions:
0

Re: Remove product from Bread Crumb Trail

Actually I want to just remove the product from the breadcrumb on all pages.

Changing:
Home :: Stereos :: Philips :: Philips TG125 Portable Radio

To just:
Home :: Stereos :: Philips

The TG125 being a product, not a category. But thanks clydejones for your code to remove the crumbs from the main page -- I hadn't thought about that but it's much more clean. :)

Anybody know how to remove the product so it only displays categories in the breadcrumb? I'm running 1.3.0.1. Thanks!

Currently using ZEN CART v. 1.3.6

20 May 2006, 3:15 AM
#4
aeolidia avatar

aeolidia

Zen Follower

Join Date:
Mar 2005
Posts:
166
Plugin Contributions:
0

Re: Remove product from Bread Crumb Trail

I would like to ideally truncate the breadcrumb after a certain number of characters. Anybody have a quick tip on how to do that? I think that might solve magicpants' problem as well.

20 May 2006, 3:41 AM
#5
danielcor avatar

danielcor

New Zenner

Join Date:
May 2006
Posts:
14
Plugin Contributions:
0

Re: Remove product from Bread Crumb Trail

This will limit the breadcrumbs length.. It won't truncate exactly, so you will always get complete crumbs, but it will truncate so that as soon as the total length goes over $max_trail in the code below:

function trail($separator = '  ') {
$trail_string = '';

$trail_len = 0;

$max_trail = 20;

for ($i=0, $n=sizeof($this->_trail); $i<$n; $i++) {

// echo 'breadcrumb ' . $i . ' of ' . $n . ': ' . $this->_trail[$i]['title'] . '<br />';
$skip_link = false;
if ($i==($n-1) && DISABLE_BREADCRUMB_LINKS_ON_LAST_ITEM =='true')
{
$skip_link = true;
}

  if (isset($this->_trail[$i]['link']) && zen_not_null($this->_trail[$i]['link']) && !$skip_link )
{
    // this line simply sets the "Home" link to be the domain/url, not main_page=index?blahblah:
     if ($this->_trail[$i]['title'] == HEADER_TITLE_CATALOG)
   {
         $trail_string .= '  <a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . $this->_trail[$i]['title'] . '</a>';
     }
   else
   {
        $trail_string .= '  <a href="' . $this->_trail[$i]['link'] . '">' . $this->_trail[$i]['title'] . '</a>';
     }
  }
else
{
    $trail_string .= $this->_trail[$i]['title'];
  }

  if (($i+1) < $n) $trail_string .= $separator;
  
$trail_string .= "\n";

$trail_len += strlen($this->_trail[$i]['title']) + strlen($separator);

if ($trail_len > $max_trail)
	break;
}

return $trail_string;

}

Just replace the function trail with the code above, and adjust max_trail according to your desired length.

  • Daniel
20 May 2006, 3:48 AM
#6
danielcor avatar

danielcor

New Zenner

Join Date:
May 2006
Posts:
14
Plugin Contributions:
0

Re: Remove product from Bread Crumb Trail

By the way, that code is in breadcrumb.php. My next post will explain how to remove the product from the end of the breadcrumb!

20 May 2006, 3:50 AM
#7
danielcor avatar

danielcor

New Zenner

Join Date:
May 2006
Posts:
14
Plugin Contributions:
0

Re: Remove product from Bread Crumb Trail

Magicpants is looking for this:

In init_add_crumbs.php, comment out the following code:

/**

  • add the products model to the breadcrumb trail
    */
    if (isset($_GET['products_id'])) {
    $productname_query = "select products_name
    from " . TABLE_PRODUCTS_DESCRIPTION . "
    where products_id = '" . (int)$_GET['products_id'] . "'
    and language_id = '" . $_SESSION['languages_id'] . "'";

$productname = $db->Execute($productname_query);

if ($productname->RecordCount() > 0) {
$breadcrumb->add($productname->fields['products_name'], zen_href_link(zen_get_info_page($_GET['products_id']), 'cPath=' . $cPath . '&products_id=' . $_GET['products_id']));
}
}

20 May 2006, 7:38 AM
#8
magicpants avatar

magicpants

Zen Follower

Join Date:
Aug 2005
Posts:
314
Plugin Contributions:
0

Re: Remove product from Bread Crumb Trail

Thanks Daniel! I never even noticed that init_add_crumbs file. Easier than I was expecting... :thumbsup:

Currently using ZEN CART v. 1.3.6

20 May 2006, 7:44 AM
#9
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Remove product from Bread Crumb Trail

Instead of messing with the Core Code you can do the same thing in your includes -> templates -> YOURTEMPLATE -> common -> tpl_main_page.php

use the following:

<!-- bof  breadcrumb -->
<?php if (DEFINE_BREADCRUMB_STATUS == '1' && ($current_page!='index' || (int)$cPath>0 )) { ?>    <div id="navBreadCrumb"><?php echo $breadcrumb->trail(BREAD_CRUMBS_SEPARATOR); ?></div>
<?php } ?>
<!-- eof breadcrumb -->

NOTE: We are sorry that Clyde is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

20 May 2006, 4:13 PM
#10
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Remove product from Bread Crumb Trail

Sorry about the above post- I thought I'd figured out a way to use this by changing the current page == product_info but that eliminates the entire breadcrumb on that page. - Not what you want.

NOTE: We are sorry that Clyde is no longer with us.
We are grateful for all his contributions to the Zen Cart community.