Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Category/Product listing problem


hare_sa

Recommended Posts

Hi,

 

I have problems with category listing ... When I add category to osc I get the listing on the left in main menu and in the middle of the body page with thunmbnail picture ... so the problem is ... If I click on category

on the left in main menu it will show the right category ... but, if I click in the middle where category is listed with thumbnail picture it will open different category ... I am not sure where to look to fix this problem. Any help is greatly apprechiated. Thanks you in advance.

Link to comment
Share on other sites

Hard to say... Usually there are comments for the contributions in the PHP files. But since I don't know what you are exactly using, I can't tell you.

 

Ok, let's say that I do not have any contributions installed ... where to go I what to look to fix this problem?

 

Thanks

Link to comment
Share on other sites

Usually it's been found in your index.php between line 80 and 110. When you're using a template system things might be different.

 

This is what have between line 74 and 150

 

<?php

if (isset($cPath) && strpos('_', $cPath)) {

// check to see if there are deeper categories within the current category

$category_links = array_reverse($cPath_array);

for($i=0, $n=sizeof($category_links); $i<$n; $i++) {

$categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");

$categories = tep_db_fetch_array($categories_query);

if ($categories['total'] < 1) {

// do nothing, go through the loop

} else {

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");

break; // we've found the deepest category the customer is in

}

}

} else {

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");

}

 

$number_of_categories = tep_db_num_rows($categories_query);

$rows = 0;

while ($categories = tep_db_fetch_array($categories_query)) {

 

$p_pic_sub = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a>';

 

$p_name_sub = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . $categories['categories_name'] . '</a>';

 

 

 

$rows++;

$cPath_new = tep_get_path($categories['categories_id']);

$width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';

echo '

 

<td align="center" width="' . $width . '">

<table cellpadding="0" cellspacing="0" border="0" style="height:195px">

<tr>

<td style="height:55px; border:1px solid #fcf9f2; border-width:0 0 0 25px" class="vam" >'.$p_name_sub.'</td>

</tr>

<tr>

<td style="height:114px " class="pic" align="center">'.$p_pic_sub .'</td>

</tr>

<tr>

<td><img alt="" src="images/spacer.gif" width="1" height="26"></td>

</tr>

</table>

</td>

' . "\n";

if ($col!=(MAX_DISPLAY_CATEGORIES_PER_ROW-1)){

echo '

<td class="bg_vv_1">'.tep_draw_separator('spacer.gif', '9', '1').'</td>

';

}

else{

 

if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {

echo '

</tr><tr><td colspan="'.(MAX_DISPLAY_CATEGORIES_PER_ROW + MAX_DISPLAY_CATEGORIES_PER_ROW -1).'">'.tep_draw_separator('spacer.gif', '1', '10').'</td></tr>' . "\n";

echo ' <tr>' . "\n";

}

}

if ($col==MAX_DISPLAY_CATEGORIES_PER_ROW-1){

$col=0;

}else{

$col++;

}

}

 

// needed for the new products module shown below

$new_products_category_id = $current_category_id;

?>

 

</table>

 

<? tep_draw_heading_bottom_4();?>

 

<? tep_draw_heading_bottom(); ?>

 

<?php /* tep_draw_separate(); */ ?> <!-- ///////// -->

Link to comment
Share on other sites

If I read that code the right way, it should be that any category link points exactly to the category listed left to it. Is that correct?

 

category links to category on the right side!

Link to comment
Share on other sites

OK,

Now I know what you are talking about.. .

 

Correct links:

In the category display on left Oriental Food links to http://condimento.ba/index.php?cPath=13

and then

Preserved Food and Vegetables links to http://condimento.ba/index.php?cPath=13_17

Dried fruits & vegetables links to http://condimento.ba/index.php?cPath=13_18

 

 

Incorrect links

In the middle section of your store

Preserved Food and Vegetables links to http://condimento.ba/index.php [and this is where the problem starts]

Dried fruits & vegetables links to http://condimento.ba/index.php?cPath=13_17

 

So the links are losing reference at some place - and thus open up incorrect category.

Best Regards,
Gaurav

Link to comment
Share on other sites

So here is what I would suggest you to do

a. Check code in categories.php [in catalog\includes\boxes]

b. Take a back up of your existing file and replace with a standard version

c. Test and update what is the outcome

 

or if you could dig in the code - figure out why first link doesn't get child category id [x_yy] and instead gets index.php - and remaining files are shifted by one [x_13 instead of x_12] as I have highlighted in previous post.

 

Cheers

Best Regards,
Gaurav

Link to comment
Share on other sites

So here is what I would suggest you to do

a. Check code in categories.php [in catalog\includes\boxes]

b. Take a back up of your existing file and replace with a standard version

c. Test and update what is the outcome

 

or if you could dig in the code - figure out why first link doesn't get child category id [x_yy] and instead gets index.php - and remaining files are shifted by one [x_13 instead of x_12] as I have highlighted in previous post.

 

Cheers

 

I have replaced /includes/boxes/categories.php and same thing ... nothing happened! Same problem!

Link to comment
Share on other sites

I have replaced /includes/boxes/categories.php and same thing ... nothing happened! Same problem!

 

So you need to debug - where is the ref being lost

 

I often make use of echo to begin tracking - and you may try to find out using example below to track where and why does cpath value fail.

 

// Example code - Use at your own risk

if ($tree[$counter]['parent'] == 0) {
  $cPath_new = 'cPath=' . $counter;
echo "IN IF CPATH is ".$cPath_new."</BR>";
} else {
  $cPath_new = 'cPath=' . $tree[$counter]['path'];
echo "IN ELSE CPATH is ".$cPath_new."</BR>";
}

Best Regards,
Gaurav

Link to comment
Share on other sites

cPath_new is defined too late at the while loop...

 

Place the cPath_new = ... statement right behind the start of the while loop and you should be good to go.

 

I am not sure where to place cPath_new ... can you give some more instructions or copy/paste example code? Thanks

Link to comment
Share on other sites

From the code you have pasted...

$cPath_new = tep_get_path($categories['categories_id']);

is being populated late and thus first reference is getting lost.

 

while ($categories = tep_db_fetch_array($categories_query)) {

$p_pic_sub = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a>';

$p_name_sub = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . $categories['categories_name'] . '</a>';



  $rows++;
  $cPath_new = tep_get_path($categories['categories_id']);
  $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
  echo '			   

	<td  align="center" width="' . $width . '">
	<table cellpadding="0" cellspacing="0" border="0" style="height:195px">
		<tr>
<td style="height:55px; border:1px solid #fcf9f2; border-width:0 0 0 25px" class="vam" >'.$p_name_sub.'</td>
		</tr>
		<tr>
			<td style="height:114px " class="pic" align="center">'.$p_pic_sub .'</td>
		</tr>	
		<tr>
			<td><img alt="" src="images/spacer.gif" width="1" height="26"></td>
		</tr>												
	</table> 
	</td>
  ' . "\n";
			  if ($col!=(MAX_DISPLAY_CATEGORIES_PER_ROW-1)){
			  echo '
					<td class="bg_vv_1">'.tep_draw_separator('spacer.gif', '9', '1').'</td>					
					';
			  }

 

 

So modify your code to declare $cPath_new as shown below

 

 while ($categories = tep_db_fetch_array($categories_query)) {
	$cPath_new = tep_get_path($categories['categories_id']);

$p_pic_sub = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a>';

$p_name_sub = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . $categories['categories_name'] . '</a>';



	  $rows++;

	  $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
	  echo '			   

		<td  align="center" width="' . $width . '">
	 <table cellpadding="0" cellspacing="0" border="0" style="height:195px">
		 <tr>
 <td style="height:55px; border:1px solid #fcf9f2; border-width:0 0 0 25px" class="vam" >'.$p_name_sub.'</td>
		 </tr>
		 <tr>
			 <td style="height:114px " class="pic" align="center">'.$p_pic_sub .'</td>
		 </tr>	
		 <tr>
			 <td><img alt="" src="images/spacer.gif" width="1" height="26"></td>
		 </tr>												
	 </table> 
		</td>
	  ' . "\n";
				  if ($col!=(MAX_DISPLAY_CATEGORIES_PER_ROW-1)){
				  echo '
						<td class="bg_vv_1">'.tep_draw_separator('spacer.gif', '9', '1').'</td>					
						';
				  }

 

Check and update!!!

 

Nice catch @ Nullachtfuffzehn :)

Best Regards,
Gaurav

Link to comment
Share on other sites

So that you can compare... the default version has following code from line 100 to 108 - and we are talking about this part of code in index.php.

 

Also I notice that $rows++; has to be placed before $cPath_new

 

while ($categories = tep_db_fetch_array($categories_query)) {
$rows++;
$cPath_new = tep_get_path($categories['categories_id']);

$width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
echo '				<td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n";


if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
echo '			  </tr>' . "\n";
echo '			  <tr>' . "\n";
}
}

 

HTH

Best Regards,
Gaurav

Link to comment
Share on other sites

From the code you have pasted...
$cPath_new = tep_get_path($categories['categories_id']);

is being populated late and thus first reference is getting lost.

 

while ($categories = tep_db_fetch_array($categories_query)) {

$p_pic_sub = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a>';

$p_name_sub = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . $categories['categories_name'] . '</a>';



  $rows++;
  $cPath_new = tep_get_path($categories['categories_id']);
  $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
  echo '			   

	<td  align="center" width="' . $width . '">
	<table cellpadding="0" cellspacing="0" border="0" style="height:195px">
		<tr>
<td style="height:55px; border:1px solid #fcf9f2; border-width:0 0 0 25px" class="vam" >'.$p_name_sub.'</td>
		</tr>
		<tr>
			<td style="height:114px " class="pic" align="center">'.$p_pic_sub .'</td>
		</tr>	
		<tr>
			<td><img alt="" src="images/spacer.gif" width="1" height="26"></td>
		</tr>												
	</table> 
	</td>
  ' . "\n";
			  if ($col!=(MAX_DISPLAY_CATEGORIES_PER_ROW-1)){
			  echo '
					<td class="bg_vv_1">'.tep_draw_separator('spacer.gif', '9', '1').'</td>					
					';
			  }

 

 

So modify your code to declare $cPath_new as shown below

 

 while ($categories = tep_db_fetch_array($categories_query)) {
	$cPath_new = tep_get_path($categories['categories_id']);

$p_pic_sub = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a>';

$p_name_sub = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . $categories['categories_name'] . '</a>';



	  $rows++;

	  $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
	  echo '			   

		<td  align="center" width="' . $width . '">
	 <table cellpadding="0" cellspacing="0" border="0" style="height:195px">
		 <tr>
 <td style="height:55px; border:1px solid #fcf9f2; border-width:0 0 0 25px" class="vam" >'.$p_name_sub.'</td>
		 </tr>
		 <tr>
			 <td style="height:114px " class="pic" align="center">'.$p_pic_sub .'</td>
		 </tr>	
		 <tr>
			 <td><img alt="" src="images/spacer.gif" width="1" height="26"></td>
		 </tr>												
	 </table> 
		</td>
	  ' . "\n";
				  if ($col!=(MAX_DISPLAY_CATEGORIES_PER_ROW-1)){
				  echo '
						<td class="bg_vv_1">'.tep_draw_separator('spacer.gif', '9', '1').'</td>					
						';
				  }

 

Check and update!!!

 

Nice catch @ Nullachtfuffzehn :)

 

This one works great so far. Thanks a lot. Sorry for late answer.

 

I have one problem :) ... I have that yellow background on the right side. I have went through CSS and index.php ... I could not find a locate and color code that refferes to this yellow I have on the right side. Is there a way you can chek it out through my code?

 

Thanks a lot for all your help.

Link to comment
Share on other sites

This one works great so far. Thanks a lot. Sorry for late answer.

 

I have one problem :) ... I have that yellow background on the right side. I have went through CSS and index.php ... I could not find a locate and color code that refferes to this yellow I have on the right side. Is there a way you can chek it out through my code?

 

Thanks a lot for all your help.

 

any help on this yellow background? Thanks

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...