Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Change breadcrumb


shahed

Recommended Posts

Hello I like to change breadcrumb, currently when user view a product it shows model name on breadcrumb but I like to use name of the product instead of model. can anyone tell which file to change and what do I have to change?

Thanks

Shahed

Link to comment
Share on other sites

can anyone tell which file to change and what do I have to change?

 

look in catalog/includes/application_top.php lines 438 - 442

 

  if ($HTTP_GET_VARS['products_id']) {

   $model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "'");

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

 }

 

just change that to echo the product name instead of model :)

Mark Evans

osCommerce Monkey & Lead Guitarist for "Sparky + the Monkeys" (Album on sale in all good record shops)

 

---------------------------------------

Software is like sex: It's better when it's free. (Linus Torvalds)

Link to comment
Share on other sites

I just tried this and it worked...

 

In the 2.2 snapshot the code appears to be in application_top.php at line 439 ..

if ($HTTP_GET_VARS['products_id']) {

$model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "'");

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

}

 

CHANGE

 

$model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "'");

 

TO

 

$product_bc_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "'");

 

 

AND

 

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

}

 

TO

 

$product_bc = tep_db_fetch_array($product_bc_query);

$breadcrumb->add($product_bc['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));

 

 

----

Note in the final snippit there is a } missing .. I had to remove that to make mine work.

 

-caz :wink:

Link to comment
Share on other sites

  • 4 months later...

Little problem with the last block of code as it does not get the right language for multilanguage site.

 

Instead of this:

 

$product_bc_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "'");

 

Use this:

 

  if ($HTTP_GET_VARS['products_id']) {

   $product_bc_query = tep_db_query("select p.products_id, pd.products_name, from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.language_id = '" . $languages_id . "'"); $product_bc = tep_db_fetch_array($product_bc_query); 

$breadcrumb->add($product_bc['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id'])); // set which precautions should be checked

}

 

to get the right language.

 

My brand new snapshot did not mind the original "}" so it is included.

"Use no way as way, have no limitation as limitation." - Bruce Lee

Link to comment
Share on other sites

Sorry, one extra "," before from. :oops:

 

 if ($HTTP_GET_VARS['products_id']) { 

   $product_bc_query = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.language_id = '" . $languages_id . "'"); $product_bc = tep_db_fetch_array($product_bc_query); 

$breadcrumb->add($product_bc['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id'])); // set which precautions should be checked 

}

"Use no way as way, have no limitation as limitation." - Bruce Lee

Link to comment
Share on other sites

  • 1 month later...

thanks I did all that and it works fine!

 

One thing though, on both breadcrumb trails there is an extra >> after the end of the trail. Not sure where this is coming from?

 

You can see it at:

http://www.redinstead.com.au/catalog/produ...?products_id=31

 

Any ideas what I need to edit?

 

 

Jen

I haven't lost my mind - I have it backed up on disk somewhere.

Link to comment
Share on other sites

Cool,

 

haven't thought of that one yet...lol

 

thanks

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

  • 2 weeks later...
Sorry, one extra "," before from. :oops:  

 

 if ($HTTP_GET_VARS['products_id']) { 

   $product_bc_query = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.language_id = '" . $languages_id . "'"); $product_bc = tep_db_fetch_array($product_bc_query); 

$breadcrumb->add($product_bc['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id'])); // set which precautions should be checked 

}

 

I am sorry but inserting this code I get:

Parse error: parse error, unexpected T_STRING in C:Documents and SettingsPeter FjelstenMy DocumentsHTMLWWWrootcatalogincludesapplication_top.php on line 449

Fatal error: Call to undefined function: tep_not_null() in C:Documents and SettingsPeter FjelstenMy DocumentsHTMLWWWrootcatalogdefault.php on line 17

 

Thie first error is in this line

? ? $product_bc_query = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.language_id = '" . $languages_id . "'"); $product_bc = tep_db_fetch_array($product_bc_query);

 

And the second is in this line:

  if (isset($cPath) && tep_not_null($cPath)) {

 

I wonder if anybody can help?

Link to comment
Share on other sites

  • 3 weeks later...
thanks I did all that and it works fine!

 

One thing though, on both breadcrumb trails there is an extra >> after the end of the trail. Not sure where this is coming from?

 

You can see it at:

http://www.redinstead.com.au/catalog/produ...?products_id=31

 

Any ideas what I need to edit?

 

 

Jen

 

BUMP to see if anybody's got an answer for this one.

Have you ever gotten any help from these forums? Be part of the community and help out by answering a question or 2.

Pass on what you know about OSC to someone who needs help.

Link to comment
Share on other sites

BUMPING IS NOT ALLOWED!!!!

 

:( Sorry.

 

FWIW, I saw some thread today where a guy bumped his own post after a number of hours of no replies and all he got was a lot of help

 

I certainly don't think that reviving a 2-week old unaswered thread is nearly as bad as that (his own thread, the same day, after only hours) but next time I'll just say "Hey, I was wondering the same thing. Has anybody figured this out yet?"

 

And your response here http://www.oscommerce.com/forums/viewtopic.php...ustomergreeting to a person who bumped their own thread after receiving NO replies to their own question was quite different than your response to my post.

 

But whatever, it won't happen again.

Have you ever gotten any help from these forums? Be part of the community and help out by answering a question or 2.

Pass on what you know about OSC to someone who needs help.

Link to comment
Share on other sites

Let's not start a big fight over this. It was my question that he bumped.

 

Any chance of an answer seeing as how it has been revived? I still haven't figured it out.

 

Jen

I haven't lost my mind - I have it backed up on disk somewhere.

Link to comment
Share on other sites

The last >> points to where your product number would go if you had one. I just removed it on my store by commenting out

    $breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));

near the bottom of includes/application_top.php. Thanks for point it out, it looks kind of weird to end the line with >>.

 

To Waza04: If people trying to help are going to have the rules thrown at them, I want to know when payday is.

In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:

Link to comment
Share on other sites

The last >> points to where your product number would go if you had one.  I just removed it on my store by commenting out
    $breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));

near the bottom of includes/application_top.php.  Thanks for point it out, it looks kind of weird to end the line with >>.

 

To Waza04: If people trying to help are going to have the rules thrown at them, I want to know when payday is.

 

Sorry guys, but bumping is against forum rules. The other thread probably got told too.

Steve

-------------------------

Link to comment
Share on other sites

Sorry guys, but bumping is against forum rules. The other thread probably got told too.
What do guys get for enforcing the rules? The bump got a problem solved, which is what I thought the forums are trying to accomplish.

 

I'm not suggesting anarchy, but unless you always drive under the speed limit, wear your set belt, get a permit before removing an electrical wall plate in your house, pay income taxes on your barter transactions (like exchanging free advice which has value in a forum like this), etc, give it a rest.

In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:

Link to comment
Share on other sites

Thanks heaps Orchard! Much better now! :)

 

The last >> points to where your product number would go if you had one. I just removed it on my store by commenting out

 

I do have Model Numbers but didn't have the line you mentioned above - I must have gotten rid of it when I changed the breadcrumb to show name instead of model. I did however have two of the following line:

 

 $product_bc = tep_db_fetch_array($product_bc_query); 

 $breadcrumb->add($product_bc['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id'])); 

 }

 

I commented one out and the extra >> is gone! YAY

 

thanks

 

Jen

I haven't lost my mind - I have it backed up on disk somewhere.

Link to comment
Share on other sites

  • 1 year later...

More than a year after, this thread was useful to me.

 

I did:

// MODIFICATION! TOPIC 24033 of forums.oscommerce

// BELOW: THE ORIGINAL BREADCUMB

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

//    }

//  }

// NOW; THE MODIFIED BREADCRUMB:

// 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'] . "'");

    $product_bc_query = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.language_id = '" . $languages_id . "'"); $product_bc = tep_db_fetch_array($product_bc_query);

    if (tep_db_num_rows($model_query)) {

      $model = tep_db_fetch_array($model_query);

      $breadcrumb->add($product_bc['products_name']." [". $model['products_model'] ."]", tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));

    }

  }

 

And now I get "category >> subcategory >> product_description [product_model]".

Product description is language compatible.

 

SGershon

If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Link to comment
Share on other sites

  • 8 months later...

SGershon, your code is the only solution that works for me. I didn't want the model number to show in the breadcrumb, so i just removed the [". $model['products_model'] ."] on the 4th last line, so it looks like this:

$breadcrumb->add($product_bc['products_name']."", tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));

 

Thanks again!

 

Cheers

Link to comment
Share on other sites

thanks I did all that and it works fine!

One thing though, on both breadcrumb trails there is an extra >> after the end of the trail.  Not sure where this is coming from? 

You can see it at:

http://www.redinstead.com.au/catalog/produ...?products_id=31

Any ideas what I need to edit?

Jen

 

I'm not seeing it... did you fix it already?

Link to comment
Share on other sites

You need to edit application_top.php Elizabeth

 

Kind Regards

 

Dave

 

 

My code is usually a little different from everybody elses which is making things a bit harder for me. The following is my code starting at line 635 for includes/application_top.php. I believe what I need to change to get the breadcrumbs to show product name instead of model is within this section of code... I just want to be very careful and make sure I change it exactly right. Thanks.

 

// include the breadcrumb class and start the breadcrumb trail
 require(DIR_WS_CLASSES . 'breadcrumb.php');
 $breadcrumb = new breadcrumb;

 $breadcrumb->add(Home, tep_href_link(FILENAME_DEFAULT));

// add category names or the manufacturer name to the breadcrumb trail
 if (isset($cPath_array)) {
   for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
     $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
     if (tep_db_num_rows($categories_query) > 0) {
       $categories = tep_db_fetch_array($categories_query);
       $breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
     } else {
       break;
     }
   }
 } elseif (isset($HTTP_GET_VARS['manufacturers_id'])) {
   $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
   if (tep_db_num_rows($manufacturers_query)) {
     $manufacturers = tep_db_fetch_array($manufacturers_query);
     $breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']));
   }
 }

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

Link to comment
Share on other sites

OK

 

// include the breadcrumb class and start the breadcrumb trail
require(DIR_WS_CLASSES . 'breadcrumb.php');
$breadcrumb = new breadcrumb;

$breadcrumb->add(Home, tep_href_link(FILENAME_DEFAULT));

// add category names or the manufacturer name to the breadcrumb trail
if (isset($cPath_array)) {
  for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
    $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
    if (tep_db_num_rows($categories_query) > 0) {
      $categories = tep_db_fetch_array($categories_query);
      $breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
    } else {
      break;
    }
  }
} elseif (isset($HTTP_GET_VARS['manufacturers_id'])) {
  $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
  if (tep_db_num_rows($manufacturers_query)) {
    $manufacturers = tep_db_fetch_array($manufacturers_query);
    $breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']));
  }
}

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

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

 

Try that

 

Kind Regards

 

Dave

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...