PDA

View Full Version : Changes to breadcrumbs



gagne
06-07-2009, 06:36 AM
I changed the model# to product name in the breadcrumb trail with the codes changes in the community add-ons.

Only one problem... the product name's are in 2 different languages and the model # was the same for both.

I tried to copy the categories's codes but it doesn't work...

In the catalog/includes/application_top.php


// add the products NAME to the breadcrumb trail
if (isset($HTTP_GET_VARS['products_id'])) {
for ($i=0, $n=sizeof($tPath_array); $i<$n; $i++) {
$model_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$tPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
if (tep_db_num_rows($model_query)) {
$model = tep_db_fetch_array($model_query);
$breadcrumb->add($model['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
}
}
}

jpf
06-07-2009, 03:29 PM
Product name is stored in product_description table but model (which does not normally change between languages) is stored in product table.

Don't look for Model number in product_description as it does not exist.

So if you change the breadcrumb to Model number --- it will be the same regardless of language.

gagne
06-08-2009, 02:36 AM
It's the other way around..;)

I want to have the name instead of the model... but can not get the name in different language in TABLE_PRODUCTS_DESCRIPTION.

something with the array:rolleyes::confused:

jpf
06-08-2009, 04:08 PM
Code looks alot easier if you use a bit of the forum feature like code posting
like
put php code here or
put html code here or
some other code here

Which looks like:

put php code here or
put html code here or
some other code here


Now your code looks like


// add the products NAME to the breadcrumb trail
if (isset($HTTP_GET_VARS['products_id'])) {
for ($i=0, $n=sizeof($tPath_array); $i<$n; $i++) {
$model_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$tPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
if (tep_db_num_rows($model_query)) {
$model = tep_db_fetch_array($model_query);
$breadcrumb->add($model['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
}
}
}

Not too sure why you have a FOR loop....How many bread crumbs did you want?

Are you trying to do Replace "Product Model" with "Product Name" in Breadcrumb Trail (http://www.oscommerce.com/community/contributions,5807) this or Change Final Breadcrumb-Trail Item from Model# (http://www.oscommerce.com/community/contributions,1554) ?

In catalog/includes/application_top.php
FIND:


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

REPLACE WITH:


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

gagne
06-09-2009, 03:49 AM
Made the changes and now everything is working... Thanks for the great help.

jpf
06-09-2009, 06:06 AM
Great! Thanks for posting your results!