Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2005
    Posts
    336
    Plugin Contributions
    0

    Default 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.

  2. #2
    Join Date
    Nov 2005
    Location
    Colorado Springs, CO USA
    Posts
    7,033
    Plugin Contributions
    31

    Default Re: Remove product from Bread Crumb Trail

    I use this code
    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.

  3. #3
    Join Date
    Aug 2005
    Posts
    336
    Plugin Contributions
    0

    Default 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!

  4. #4
    Join Date
    Mar 2005
    Posts
    174
    Plugin Contributions
    0

    Default 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.

  5. #5
    Join Date
    May 2006
    Posts
    14
    Plugin Contributions
    0

    Idea or Suggestion 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 = '&nbsp;&nbsp;') {
    $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

  6. #6
    Join Date
    May 2006
    Posts
    14
    Plugin Contributions
    0

    Default 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!

  7. #7
    Join Date
    May 2006
    Posts
    14
    Plugin Contributions
    0

    Default 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']));
    }
    }

  8. #8
    Join Date
    Aug 2005
    Posts
    336
    Plugin Contributions
    0

    Default Re: Remove product from Bread Crumb Trail

    Thanks Daniel! I never even noticed that init_add_crumbs file. Easier than I was expecting...
    Currently using ZEN CART v. 1.3.6

  9. #9
    Join Date
    Nov 2005
    Location
    Colorado Springs, CO USA
    Posts
    7,033
    Plugin Contributions
    31

    Default 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:

    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 -->

  10. #10
    Join Date
    Nov 2005
    Location
    Colorado Springs, CO USA
    Posts
    7,033
    Plugin Contributions
    31

    Default 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.

 

 

Similar Threads

  1. bread crumb positioning
    By signify in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 5 Feb 2011, 02:31 PM
  2. bread crumb question
    By andy in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 6 Feb 2007, 12:27 AM
  3. Cant remove bread crumb please help!!
    By lori2472 in forum General Questions
    Replies: 3
    Last Post: 9 Aug 2006, 06:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg