Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Show categories and subcategories


Guest

Recommended Posts

Posted

Hi there,

 

I did some modification to the way the "new" products are shown. Now I would like to use the same style for my categories and sub categories.

 

To clearify... When I click on a main category I get a page with a list of sub categories and the new products underneith. I want to get rid of that and display all products of this main categorie in the same style as the new products.

 

This way the only way to get to a sub category would be the menu on the left, but that's OK. When I now click on a sub category the products shown a limited to that sub category and so on.

 

One way would be to change the file <b>product_listing.php</b> somehow similar to <b>new_products.php</b> and use the appropriate SQL statement (whatever that would be).

 

I am somehow a little scared since there are so many "functions" within the default.php that effect what will be shown on the <b>product_listing.php</b>, that I will detsroy needed functionality without knowing.

 

Please help :idea:

 

Regards Matt

Posted

I believe you ment this contribution http://www.oscommerce.com/community/contributions,1145?

 

But that's not what I am looking for. Remeber the way the new products are displayed? I would like to have all products displayed that way directly when you click the category in the left menu.

 

e.g. When you click on a top category that contains, let's say 50 products, and you click on this catgeory you'll see all 50 products out of that category (of course being split into x pages). When you now click on a subcategory that contains 20 prodcuts you would see the same style page, but the output now is limted to the products within this subcategory.

 

Clear?

 

Thanks Matt

  • 2 weeks later...
Posted

Did you ever figure out how to do this?

I'm wondering about the same thing!

 

Your thoughts are much appreciated!

Thanks much!

Posted

Hi CodeConfused,

 

yes I solved it. I will post some code underneith hoping that this helps.

 

$cPathA = explode("_", $cPath);

$size = sizeof($cPathA)-1;

$subcategories_array = array();

tep_get_subcategories($subcategories_array, $cPathA[$size]);

$size_sc = sizeof($subcategories_array);

for($i = 0; $i < $size_sc; $i++){

$cat_Search .= "p2c.categories_id = '" . $subcategories_array[$i] . "' or ";

}

$cat_Search .= "p2c.categories_id = '" . $cPathA[$size] . "'";

 

$result = tep_db_query("select p.products_id, p.products_image, p.products_price from " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_PRODUCTS . " p where p2c.products_id = p.products_id and p.products_status = '1' and (" . $cat_Search . ")");

 

Drop me a note, if that works for you. This subject is already far away to me and I am not sure, if the function "tep_get_subcategories" is a standard one or written/modified by me. We've put more than 400 hours into our osCommerce project by now, so it gets hard to remember everything we did ;-)

 

Best regards Matt

Posted

It was a pleasure, especially that I might have been able to give something back, after so much help from so many people in this forum.

 

Regards and also thanks,

 

Matt :D

  • 3 months later...
  • 4 weeks later...
Posted

Where did you use this code... I am trying to find out how to implement it.

 

Kim

  • 1 year later...
Posted

I see around the forum that quite a few people wanted this functionality, including myself, but no clear solution was presented as I could locate.

 

I borrowed some of the code from a previous post that does most of the hard work.

As I am a PHP newbie, I apologise for the somewhat crude approach, but I got it working and that's the main thing for me. Feel free to polish it up. ;)

 

The file to be edited is catalog/index.php

 

First, since I never want categories or subcategories headings in the main panel, I makes sure that if there are any products in the current category or in a subcategory a product listing will appear, like this:

 

At around line 20 find

 

if ($cateqories_products['total'] > 0) {

$category_depth = 'products'; // display products

} else {

 

 

replace with

 

// Begin show all subcategories mod.

if (tep_count_products_in_category($cPath) > 0) {

// End show all subcategories mod.

$category_depth = 'products'; // display products

} else {

 

 

 

Then the actual search in the database has to be modified to include all subcategories, like this:

 

 

At around line 186 find

 

// We show them all

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";

}

}

 

 

Replace with

 

 

 

// We show them all

 

// Begin show all subcategories mod.

 

$cPathA = explode("_", $cPath);

$size = sizeof($cPathA)-1;

$subcategories_array = array();

tep_get_subcategories($subcategories_array, $cPathA[$size]);

$size_sc = sizeof($subcategories_array); //Subcat count

$cat_Search = "(";

for($i = 0; $i < $size_sc; $i++){

$cat_Search .= "p2c.categories_id = '" . $subcategories_array[$i] . "' or ";

}

$cat_Search .= "p2c.categories_id = '" . $cPathA[$size] . "'" . ")";

 

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and ". $cat_Search . "";

 

}

}

 

// End show all subcategories mod.

 

 

That's about it as far as I recall, it's been about a week since I did this and these things fade fast.

If it works for you, great. If not, post a message here and I will see what I may have overlooked.

 

cheers.

  • 2 weeks later...
Posted
// End show all subcategories mod.

That's about it as far as I recall, it's been about a week since I did this and these things fade fast.

If it works for you, great. If not, post a message here and I will see what I may have overlooked.

 

cheers.

 

works good thanks

 

 

i was wonderin maybe if anyone knows how to mod this a bit and have it list by sub category...ie

if i click hardware it would list all products but list

 

like

CDROM Drives

LIST ALL PRODUCTS FROM CDROM DRIVES

Graphics Cards (2)

LIST ALL PRODUCTS FROM GRAPHICS CARDS

Keyboards (1)

etc

etc

Posted
works good thanks

i was wonderin maybe if anyone knows how to mod this a bit and have it list by sub category...ie

if i click hardware it would list all products but list

 

like

  CDROM Drives

LIST ALL PRODUCTS FROM CDROM DRIVES

  Graphics Cards (2)

LIST ALL PRODUCTS FROM GRAPHICS CARDS

  Keyboards (1)

etc

etc

 

 

That would probably be useful for me too, I will have to think about it a bit.

Posted
I found that the following contribution worked quite well, the subcategories are listed at the top, though, maybe not exactly what your were looking for. It works fine with my mod too so all products within the current category/subcategories are displayed as well.

 

http://www.oscommerce.com/community/contri...ns,1014/page,18

Cheers.

mm i dont see it changing anything? do you mind posting a page where i can see it live in action..maybe im doin something wrong

 

thanks

  • 5 weeks later...
Posted

 

Using the mod published on this board by Athyholdt (19/02/05) I managed to get all products (including those in sub categories) showing, which is just what I wanted (thanks :D ).

 

But I've lost the list of sub-categories at the top so that the user can "drill down". The sub cats are available via the left hand nav, but I still wanted them displayed at the top. Anyone else had this problem and found a fix?

 

#######

 

For info, I looked at http://www.oscommerce.com/community/contri...ns,1014/page,18 as suggested on this board, but wasn't sure what it was providing. It seems to suggest the default behavious of osCommerce is to display all products (including those in sub cats). But I am fairly sure that the default is to display the categories only. I installed it anyway, but it had no effect on my site.

 

- Rebecca

Posted
For info, I looked at http://www.oscommerce.com/community/contri...ns,1014/page,18 as suggested on this board, but wasn't sure what it was providing.

 

"If you have product categories that have both products and subcategories, by default, OSC only displays the product listing in the main panel."

(quote from contribution)

 

This means that sub-categories does not display by default when the selected category has products.

 

This contribution fixes it so that sub-categories are listed on top when the selected category has products, as may be the case for some categories after my mod. Personally I thought I didn't need it, but when the suggestion came up earlier I found that I liked it and kept it, ref. my screenshot earlier.

 

I have to say that I don't remember if I had to tweak it to make it work, but if you still can not make it work for you I will have a go at it again.

 

 

Cheers.

  • 1 year later...
Posted

Hi,

 

As of osCommerce 2.2 Milestone 2 Update 051113, to do this modification, open catalog/index.php

 

1) Around line 20, replace

 

 	
  if ($cateqories_products['total'] > 0) {
  $category_depth = 'products'; // display products
  } else {

 

with

 

 	
  if (tep_count_products_in_category($cPath) > 0) {
  $category_depth = 'products'; // display products
  } else {

 

Same as previously.

 

2) Around line 195, replace

 

// We show them all
  $listing_sql = "select " . $_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";

 

with

 

// We show them all
  $cPathA = explode("_", $cPath);
  $size = sizeof($cPathA)-1;
  $subcategories_array = array();
  tep_get_subcategories($subcategories_array, $cPathA[$size]);
  $size_sc = sizeof($subcategories_array); //Subcat count
  $cat_Search = "(";
  for($i = 0; $i < $size_sc; $i++){
  $cat_Search .= "p2c.categories_id = '" . $subcategories_array[$i] . "' or ";
  }
  $cat_Search .= "p2c.categories_id = '" . $cPathA[$size] . "'" . ")";

  $listing_sql = "select " . $_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and " . $cat_Search . "";

 

Hope this helps.

Posted

Somebody should make this a contribution! This is a very simple yet amazing modification to the way that osCommerce works. I've been searching the contrib section for this exact modification and I think it could help a lot of people. I've never submitted a contribution but I think this one is worthy...

  • 5 months later...
Posted

Now say if you have a sub sub categories can you get it to show in the main category instead of just in the sub category?

  • 2 months later...
Posted
Now say if you have a sub sub categories can you get it to show in the main category instead of just in the sub category?

 

That is exactly what I need to - can any one help please?

 

Thanks

 

STuart

  • 2 months later...
Posted

Hi, i'm using Show Sub-categories with onmouse over v2 contribution.

 

My category list look like this:

CATEGORY1

---SUBCATEGORY1

------SUB_SUBCATEGORY1

------SUB_SUBCATEGORY2

---SUBCATEGORY2

and so on...

 

I would love to obtain this effect:

When i click on Subcategory1, in Menu will shown SUB_SUBCATEGORY1 and SUB_SUBCATEGORY2.

 

 

Now the menu show always only categories, and subcategories. When i click on subcategories - menu doesnt change.

What should I chage to obtain this effect ?

  • 2 months later...
Posted

i've tried this contribution [the latest one put up on 8/26/07], but nothing seems to really happen.

 

Here's my PHP:

 

<?php
/*
 $Id: index.php,v 1.1 2003/06/11 17:37:59 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Copyright © 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

// the following cPath references come from application_top.php
 $category_depth = 'top';
 if (isset($cPath) && tep_not_null($cPath)) {
   $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
   $cateqories_products = tep_db_fetch_array($categories_products_query);   if (tep_count_products_in_category($cPath) > 0) {

     $category_depth = 'products'; // display products

  } else {
     $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");
     $category_parent = tep_db_fetch_array($category_parent_query);
     if ($category_parent['total'] > 0) {
       $category_depth = 'nested'; // navigate through the categories
     } else {
       $category_depth = 'products'; // category has no products, but display the 'no products' message
     }
   }
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
<!-- body_text //-->
<?php
 if ($category_depth == 'nested') {
   $category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
   $category = tep_db_fetch_array($category_query);
?>
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
<?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)) {
     $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";
     }
   }

// needed for the new products module shown below
   $new_products_category_id = $current_category_id;
?>
             </tr>
           </table></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <tr>
           <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>
         </tr>
       </table></td>
     </tr>
   </table></td>
<?php
 } elseif ($category_depth == 'products' || isset($HTTP_GET_VARS['manufacturers_id'])) {
// create column list
   $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
                        'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
                        'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
                        'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
                        'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
                        'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
                        'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
                        'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

   asort($define_list);

   $column_list = array();
   reset($define_list);
   while (list($key, $value) = each($define_list)) {
     if ($value > 0) $column_list[] = $key;
   }

   $select_column_list = '';

   for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
     switch ($column_list[$i]) {
       case 'PRODUCT_LIST_MODEL':
         $select_column_list .= 'p.products_model, ';
         break;
       case 'PRODUCT_LIST_NAME':
         $select_column_list .= 'pd.products_name, ';
         break;
       case 'PRODUCT_LIST_MANUFACTURER':
         $select_column_list .= 'm.manufacturers_name, ';
         break;
       case 'PRODUCT_LIST_QUANTITY':
         $select_column_list .= 'p.products_quantity, ';
         break;
       case 'PRODUCT_LIST_IMAGE':
         $select_column_list .= 'p.products_image, ';
         break;
       case 'PRODUCT_LIST_WEIGHT':
         $select_column_list .= 'p.products_weight, ';
         break;
     }
   }

// show the products of a specified manufacturer
   if (isset($HTTP_GET_VARS['manufacturers_id'])) {
     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only a specific category
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
     } else {
// We show them all
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
     }
   } else {
// show the products in a given categorie
     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
     } else {
// We show them all

  $cPathA = explode("_", $cPath);

  $size = sizeof($cPathA)-1;

  $subcategories_array = array();

  tep_get_subcategories($subcategories_array, $cPathA[$size]);

  $size_sc = sizeof($subcategories_array); //Subcat count

  $cat_Search = "(";

  for($i = 0; $i < $size_sc; $i++){

     $cat_Search .= "p2c.categories_id = '" . $subcategories_array[$i] . "' or ";

  }

  $cat_Search .= "p2c.categories_id = '" . $cPathA[$size] . "'" . ")";



     $listing_sql = "select " . $select_column_list . " p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and " . $cat_Search . "";

     }

   }

   if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
     for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
       if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $listing_sql .= " order by pd.products_name";
         break;
       }
     }
   } else {
     $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
     $sort_order = substr($HTTP_GET_VARS['sort'], 1);
     $listing_sql .= ' order by ';
     switch ($column_list[$sort_col-1]) {
       case 'PRODUCT_LIST_MODEL':
         $listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_NAME':
         $listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
         break;
       case 'PRODUCT_LIST_MANUFACTURER':
         $listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_QUANTITY':
         $listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_IMAGE':
         $listing_sql .= "pd.products_name";
         break;
       case 'PRODUCT_LIST_WEIGHT':
         $listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_PRICE':
         $listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
     }
   }  
?>
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">


<!--


     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<?php
// optional Product List Filter
   if (PRODUCT_LIST_FILTER > 0) {
     if (isset($HTTP_GET_VARS['manufacturers_id'])) {
       $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name";
     } else {
       $filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by m.manufacturers_name";
     }
     $filterlist_query = tep_db_query($filterlist_sql);
     if (tep_db_num_rows($filterlist_query) > 1) {
       echo '            <td align="center" class="main">' . tep_draw_form('filter', FILENAME_DEFAULT, 'get') . TEXT_SHOW . ' ';
       if (isset($HTTP_GET_VARS['manufacturers_id'])) {
         echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
         $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
       } else {
         echo tep_draw_hidden_field('cPath', $cPath);
         $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS));
       }
       echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']);
       while ($filterlist = tep_db_fetch_array($filterlist_query)) {
         $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);
       }
       echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
       echo '</form></td>' . "\n";
     }
   }

// Get the right image for the top-right
   $image = DIR_WS_IMAGES . 'table_background_list.gif';
   if (isset($HTTP_GET_VARS['manufacturers_id'])) {
     $image = tep_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
     $image = tep_db_fetch_array($image);
     $image = $image['manufacturers_image'];
   } elseif ($current_category_id) {
     $image = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
     $image = tep_db_fetch_array($image);
     $image = $image['categories_image'];
   }
?>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>


-->


     <tr>
       <td><?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?></td>
     </tr>
   </table></td>
<?php
 } else { // default page
?>
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td style="padding-left:3px" valign=top>
           <?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?>
           </td>
           <td style="padding-left:3px" valign=top>

<?php


 $current_category_id = 62;
 $listing_sql = "select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c left join specials s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '1' and p2c.categories_id = '62' order by pd.products_name";
 $new_products_query = tep_db_query($listing_sql);
 echo '
             <table cellspacing=0 cellpadding=0>
              <tr><td background=images/m27.gif width=160 height=36 colspan=10 class=bc><b>      You\'ll also like</b></td></tr>
              <tr><td colspan=10 height=8 bgcolor=#F2EFF3></td></tr>
              <tr>
      ';


 while ($new_products = tep_db_fetch_array($new_products_query)) {
  $new_products['products_name'] = tep_get_products_name($new_products['products_id']);
  if (tep_not_null($new_products['specials_new_products_price'])) {
   $price = '<span style="font-size:9px"><s>' .  $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) . '</s></span><br><br style="font-size:2px"><span class=bc1>' . $currencies->display_price($new_products['specials_new_products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) . '</span>';
  } else {
   $price = '<span class=bc1>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) . '</span>';
  }
  echo '
                  <td valign=top bgcolor=#F2EFF3>
                   <table cellspacing=0 cellpadding=0 align=center width=140>
                    <tr><td valign=top width=52><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_description '], 52, 64, ' class=br') . '</a></td>
                        <td width=10></td>
                        <td valign=top width=78>
                         <table cellspacing=0 cellpadding=0>
                          <tr><td><b><a class=th9 style="text-decoration:underline" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a></b><br><br class=px2></td></tr>
                          <tr><td height=46 valign=bottom>'.$price.'</td></tr>
                         </table>
                    </td></tr>                                          
                    <tr><td colspan=10 height=31 bgcolor=#F2EFF3 align=center><hr size=1 style="color:#DBD6D6"></td></tr>
                   </table>
                  </td>

              </tr>
              <tr>
          ';
 }


 echo '
              </tr>
             </table>  
      ';


?>

           </td>
         </tr>
       </table></td>
     </tr>
   </table>


             <table cellspacing=0 cellpadding=0 align=center>
              <tr><td height=0></td></tr>
              <tr><td> </td>
              </tr>
              <tr><td> </td>
              </tr>
              <tr><td> </td>
              </tr>
             </table>

   </td>
<?php
 }
?>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

  • 2 months later...
Posted

when i did like above instruction all product images are broken. mine is RC1. any solution?

  • 1 month later...

Archived

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

×
×
  • Create New...