Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Keeping category root images...


dreamscape

Recommended Posts

Posted

hello,

 

I am trying to make it that when browsing through the categories (on default.php), that the category image in the upper right is always the root image... for example when you go into a sub category, I do not want the sub category image shown, but rather the root image always shown when in a category (will help to keep the user from getting confused by having just root images shown in the corner)...

 

this is the code that needs changed, that much I know:

      $image = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . $current_category_id . "'");

     $image = tep_db_fetch_array($image);

     $image = $image['categories_image'];

but what to change it to in order to have the categories root image show instead of the subcategory, that I do not know... can anyone help out here?

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Posted

nevermind, I figured out a simple code to do this

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Posted

yes I suppose I could :wink:

 

really simple... in application_top.php about line 420 or so replace this:

  if (strlen($cPath) > 0) {

   $cPath_array = tep_parse_category_path($cPath);

   $cPath = implode('_', $cPath_array);

   $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];

 } else {

   $current_category_id = 0;

 }

With

  if (strlen($cPath) > 0) {

   $cPath_array = tep_parse_category_path($cPath);



   $cPath = implode('_', $cPath_array);

   $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];

 } else {

   $current_category_id = 0;

 }

 

basically you are just adding:

 

$cPathl = strpos($cPath,"_");

$current_parent_id = substr($cPath,0,$cPathl);

 

to the code already there. then in default.php change the line around 270 from:

      $image = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . $current_category_id . "'");

TO:

      $image = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . $current_parent_id . "'");

 

Here you are just changing $current_category_id to _$current_parent_id

 

Now when a user is browsing through the categories, at the top level where it makes a listing of sub_categories in the top, you still have your sub category images there, but when they go into a sub category, the top level category image stays in the upper corner of the main page... really helps to keep a site together... at least I think so.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Posted

whoops... sorry.

 

In application_top.php the code you need to replace the original with (both both the original and replacement are the same above) is this:

  if (strlen($cPath) > 0) {

   $cPath_array = tep_parse_category_path($cPath);

   $cPathl = strpos($cPath,"_");

   $current_parent_id = substr($cPath,0,$cPathl);

   $cPath = implode('_', $cPath_array);

   $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];

 } else {

   $current_category_id = 0;

 }

 

there it is.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Archived

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

×
×
  • Create New...