Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Browse by Categories


Guest

Recommended Posts

akasharkbow,

 

I apologize for my quick patch code.

 

Please, replace the code

        $sub_category_links = '';
       if (tep_db_num_rows($arr_sub_categories_query) > 0) {
         $sub_icons_per_row = 1;
         while ($sub_categories = tep_db_fetch_array($arr_sub_categories_query)) {

with this code

        $sub_category_links = '<center><table cellspacing="10" cellpadding="0">'; //akasharkbow: Change CellSpacing and CellPadding
       if (tep_db_num_rows($arr_sub_categories_query) > 0) {
         $sub_icons_per_row = 1;
         $sub_category_links .= '<tr>';
         while ($sub_categories = tep_db_fetch_array($arr_sub_categories_query)) {

Down below, replace the code

          if ($arr_sub_category_mode[0] == 'right') {
           $sub_category_links .= '<br>';
         } else {
           if ($sub_icons_per_row < 2) {
             $sub_category_links .= ' ';
             $sub_icons_per_row = 1;
           } else {
             $sub_category_links .= '<br>';
             $sub_icons_per_row++;                
           }
         } // Inner If: Build Sub Category Links when Position is RIGHT.

with this code

            if ($arr_sub_category_mode[0] == 'right') {
             $sub_category_links .= '<br>';
           } else {
             if ($sub_icons_per_row >= 2) { //akasharkbow: Use the value that better suits your content box width.
               $sub_category_links .= '</td></tr>';
               $sub_icons_per_row = 1;
             } else {
               $sub_category_links .= '</td>';
               $sub_icons_per_row++;
             }
           } // Inner If: Build Sub Category Links when Position is RIGHT.

Finally, replace the code

         } // While Loop: Fetch all Query Rows. Each row is a Sub Category of current level Category.
      } // Middle If: Build Sub Category Links if they exist.
     } // Outer If: Build Sub Category Links if enabled by Configuration Settings.

with this code

          } // While Loop: Fetch all Query Rows. Each row is a Sub Category of current level Category.
         if ($sub_icons_per_row > 1) {
           $sub_category_links .= '  </tr>';
         }
         $sub_category_links .= '</table></center>';
       } // Middle If: Build Sub Category Links if they exist.
     } // Outer If: Build Sub Category Links if enabled by Configuration Settings.

Pay attention so comments starting with //akasharkbow: and that should do it. I tried on my demo osCommerce and it's working. This quick fix uses an inner table for all sub-category icons, and you should tweak the cellspacing and cellpadding, maybe even apply your own prefered styles to improve the visual appearance.

 

You may also prefer not to have a link under the category name, since it seems you prefer visitors to browse straight to the product listing of each sub-category. Note: this works only if you have top-level categories and second-level sub-categories. If you have deeper levels then the code is not suited. If you agree, then replace this code

        $content_box_contents[$row][$col] = array('align'  => 'center',
                                                 'params' => 'class="smallText" valign="top" width="' . $table_cell_width . '"',
                                                 'text'   => '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_cur, 'NONSSL') . '"><b>' .
                                                             $current_category_name . '</b></a>');

with this

        $content_box_contents[$row][$col] = array('align'  => 'center',
                                                 'params' => 'class="smallText" valign="top" width="' . $table_cell_width . '"',
                                                 'text'   => 'Browse by' . $current_category_name;

Note: the hardcoded string 'Browse by' should only be prefixed if you label the top categories with just the title. I think that in your case you already have prefixed each top-level category with 'Browse by ...', right?

Link to comment
Share on other sites

  • Replies 190
  • Created
  • Last Reply

Top Posters In This Topic

Hello there. Thanks so much so much for your help. I changed the coding for you but I didn't help. I wanted to see where the table actually showed up so I added in a border=1 and the tables show up at the end of the category.

 

You can view it her: www.dottipotts.com/store

 

Cheers,

 

David

 

 

/*
*tab-width=2
*indent=2
*width=132
*/
?>

<!-- browse_categories !-->
<?php
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_BROWSE_CATEGORIES);

 //DWD Comment: Select Heading Text for Content Box based on current category.
 if ( (!isset($browse_category_id)) || ($browse_category_id == '0') ) {
   $browse_category_id = 0;
   $browse_category_heading = BOX_HEADING_BROWSE_TOP_CATEGORIES;
 } else {
   $browse_category_heading = BOX_HEADING_BROWSE_SUB_CATEGORIES;
 } // Checks to see if current category level is top or sub.

 //DWD Comment: Select all categories of current level.
 $categories_query = "select c.categories_id, cd.categories_name, c.categories_image
                        from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                       where c.categories_id = cd.categories_id
                         and cd.language_id ='" . $languages_id . "'
                         and c.parent_id = '" . $browse_category_id . "'
                       order by c.sort_order, cd.categories_name";
 $arr_current_categories_query = tep_db_query($categories_query);

 //DWD Comment: Only show content box if there are categories at this level.
 if ((tep_db_num_rows($arr_current_categories_query) > 0) and (BRWCAT_ICON_MODE != 'off')) {

   //DWD Comment: Select parent category of current level.
   $parent_query = "select c.categories_id, cd.categories_name, c.parent_id
                      from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                     where c.parent_id = cd.categories_id
                       and cd.language_id ='" . $languages_id . "'
                       and c.categories_id = '" . $browse_category_id . "'";
   $arr_parent_category_query = tep_db_query($parent_query);
   $parent_category = tep_db_fetch_array($arr_parent_category_query);

   if ($parent_category['parent_id'] > 0) {
     //DWD Fix -> Change: Browse to parent category link from 3rd level categories to 2nd level category.
     //DWD Comment: azer Bug Request Link -> http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299469
     $content_box_text_parent = '<a href="' . tep_href_link(FILENAME_DEFAULT . '?cPath=' . $parent_category['parent_id'], 

'', 'NONSSL') . '">' . TEXT_BROWSE_PARENT_CATEGORY . $parent_category['categories_name'] . '</a>';
     //DWD Fix End.
   } else if ($browse_category_id > 0) {
     $content_box_text_parent = '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . 

TEXT_BROWSE_TOP_CATEGORY . '</a>';
   } else {
     // Top Category Level is 0, don't print back text.
   }

   $content_box_contents = array();
   $content_box_contents[] = array('align' => 'left',
                                   'text'  => $browse_category_heading);

   new contentBoxHeading($content_box_contents, true, true);

   $content_box_contents = array();
   $content_box_contents[][] = array('align'  => 'left',
                                     'params' => 'class="smallText" valign="top" colspan=2"',
                                     'text'   => $content_box_text_parent);

   $row = 1;
   $col = 0;
   while ($current_categories = tep_db_fetch_array($arr_current_categories_query)) {
     $cPath_cur = tep_get_path($current_categories['categories_id']);

     //DWD Comment: Apply Category Name Case setting to current category name.
     if (BRWCAT_NAME_CASE == 'same') {
       $current_category_name = $current_categories['categories_name'];
     } else {
       if (BRWCAT_NAME_CASE == 'upper') {
         $current_category_name = strtoupper($current_categories['categories_name']);
       } else if (BRWCAT_NAME_CASE == 'lower') {
         $current_category_name = strtolower($current_categories['categories_name']);
       } else if (BRWCAT_NAME_CASE == 'title') {
         $current_category_name = ucwords($current_categories['categories_name']);
       } else {
         //DWD Comment: Unknown Category Name Case.
       }
     }


     //DWD Comment: Select all Sub-Categories of Top-Category (Parent ID equal to Category ID).
     if (BRWCAT_SUBCAT_MODE != 'off') {
       //DWD Comment: Sort rows by Sort Order and then Name.
       $sub_query = "select c.categories_id, cd.categories_name, c.categories_image
                       from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                      where c.categories_id = cd.categories_id
                        and cd.language_id='" . $languages_id . "'
                        and c.parent_id ='" . $current_categories['categories_id'] . "'
                      order by c.sort_order, cd.categories_name";
        $arr_sub_categories_query = tep_db_query($sub_query);

       //DWD Comment: Split Sub-Category Mode in bottom or right/valign.
       $arr_sub_category_mode = explode(' ', BRWCAT_SUBCAT_MODE);

       //DWD Comment: Build Sub Category Links.
      $sub_category_links = '<center><table border=1 cellspacing="10" cellpadding="0">'; //akasharkbow: Change CellSpacing 

and CellPadding
      if (tep_db_num_rows($arr_sub_categories_query) > 0) {
        $sub_icons_per_row = 1;
        $sub_category_links .= '<tr>';
        while ($sub_categories = tep_db_fetch_array($arr_sub_categories_query)) {

           $cPath_new_sub = $cPath_cur . '_' . $sub_categories['categories_id'];


           //DWD Fix -> Change: Use Bullet Setting from Configuration Table.
           //DWD Comment: azer Feature Request Link -> 

http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299576
           $sub_category_links .= ' <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">' .
                                  tep_image(DIR_WS_IMAGES . $sub_categories['categories_image'], $sub_category_name, 

SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a><BR><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 

'NONSSL') . '">' .
                                  $sub_categories['categories_name'] . '</A>';
           //DWD Fix End.

           //DWD Comment: Spaceboy Feature Request Link -> 

http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=298901
           //DWD Comment: Feature Request Link -> 

http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299903
           if (BRWCAT_SUBCAT_COUNTS != '') {
             $products_in_category = tep_count_products_in_category($sub_categories['categories_id']);
             if ($products_in_category > 0) {
               $sub_category_links .= sprintf(' ' . BRWCAT_SUBCAT_COUNTS, $products_in_category);
             }
           }
           //DWD Fix End.

          //DWD Comment: Separate the current sub-category link from the next one.
          //DWD Comment: Separator depends on the sub-category mode.            
          if ($arr_sub_category_mode[0] == 'right') {
            $sub_category_links .= '<br>';
          } else {
            if ($sub_icons_per_row >= 2) { //akasharkbow: Use the value that better suits your content box width.
              $sub_category_links .= '</td></tr>';
              $sub_icons_per_row = 2;
            } else {
              $sub_category_links .= '</td>';
              $sub_icons_per_row++;
            }
          } // Inner If: Build Sub Category Links when Position is RIGHT.

        } // While Loop: Fetch all Query Rows. Each row is a Sub Category of current level Category.
        if ($sub_icons_per_row > 1) {
          $sub_category_links .= '  </tr>';
        }
        $sub_category_links .= '</table></center>';
      } // Middle If: Build Sub Category Links if they exist.
    } // Outer If: Build Sub Category Links if enabled by Configuration Settings.


     if ($arr_sub_category_mode[0] == 'right') {
       $table_cell_width = (100 / 1 / 2) . '%';
     } else {
       $table_cell_width = (100 / 1) . '%';
     }

     //DWD Comment: BRWCAT_ICON_MODE is set on Control Panel: Configuration->My Store.
     //DWD Comment: If Mode is set as image only then the category name will be displayed on top of sub-category links.
     //DWD Comment: azer Feature Request Link -> 

http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299469
     //DWD Comment: Feature Request Link -> http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299903
     if (BRWCAT_ICON_MODE == 'text') {
       $content_box_contents[$row][$col] = array('align'  => 'center',
                                                 'params' => 'class="smallText" valign="top" width="' . $table_cell_width . 

'"',
                                                 'text'   => '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_cur, 

'NONSSL') . '"><b>' .
                                                             $current_category_name . '</b></a>');
     } else if (BRWCAT_ICON_MODE == 'image only') {
       $content_box_contents[$row][$col] = array('align'  => 'center',
                                                 'params' => 'class="smallText" valign="top" width="' . $table_cell_width . 

'"',
                                                 'text'   => '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_cur, 

'NONSSL') . '">' .
                                                             tep_image(DIR_WS_IMAGES . 

$current_categories['categories_image'],
                                                                       $current_category_name,
                                                                       SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) .
                                                             '</a>');
       $sub_category_links = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_cur, 'NONSSL') . '"><b>' .
                             $current_category_name . '</b></a><br>' . $sub_category_links;
     } else if (BRWCAT_ICON_MODE == 'image with caption') {
       $content_box_contents[$row][$col] = array('align'  => 'center',
                                                 'params' => 'class="smallText" valign="top" width="' . $table_cell_width . 

'"',
                                                 'text'   => '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_cur, 

'NONSSL') . '">' .
                                                             tep_image(DIR_WS_IMAGES . $sub_categories['categories_image'],
                                                                       $current_category_name,
                                                                       SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) .
                                                             '</a><br><a href="' . tep_href_link(FILENAME_DEFAULT, 

$cPath_cur, 'NONSSL') . '"><b>' .
                                                             $current_category_name . '</b></a>');
     } else {
       // Unknown Browse by Categories Content Box Type.
     } // Checks Type of Content Box for Browse by Categories.

     if ($arr_sub_category_mode[0] == 'right') {
       $content_box_contents[$row][$col + 1] = array('align'  => 'left',
                                                     'params' => 'class="smallText" valign="' . $arr_sub_category_mode[1] . 

'" width="' . $table_cell_width . '"',
                                                     //DWD Fix -> Change: Show blank table cell when category has no 

sub-categories.
                                                     //DWD Comment: azer Bug Request Link -> 

http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299469
                                                     'text'   => ($sub_category_links == '' && BRWCAT_SUBCAT_MODE != 'off') 

? ' ' : $sub_category_links);
                                                     //DWD Fix End.
       $col = $col + 2;
       if ($col >= 1 * 2) {
         $col = 0;
         $row++;
       }
     } else {
       $content_box_contents[$row + 1][$col] = array('align'  => 'left',
                                                     'params' => 'class="smallText" valign="top" width="' . 

$table_cell_width . '"',
                                                     //DWD Fix -> Change: Show blank table cell when category has no 

sub-categories.
                                                     //DWD Comment: azer Bug Request Link -> 

http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299469
                                                     'text'   => ($sub_category_links == '' && BRWCAT_SUBCAT_MODE != 'off') 

? ' ' : $sub_category_links);
                                                     //DWD Fix End.
       $col++;
       if ($col >= 1) {
         $col = 0;
         $row = $row + 2;
       }
     } // Inner If: Set Content Box contents based on Sub Categories Position
   } // While Loop: Grab all current level Categories.

   new contentBox($content_box_contents);
 } // Check if there are categories at this level.
?>
<!-- browse_categories_eof !-->

Link to comment
Share on other sites

Hey there,

I have this contribution installed, but I have a problem, which I had originally thought was a feature:

 

Brouse by categories (henceforth: BBC) doesn't show when I'm in a sub-category. The only reason I could find for that, or at least - this is what drew my attention, is this segment of code I have commented out. It came that way- I don't recall editing it out myself:

~ line #90 of index.php

    // DWD Contribution -> Remove: Browse by Categories v2.2.

//    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";

//      }

//    }

    // DWD Contribution End.

Might his have anything to do with it? is there some other known cause for this?

 

Another issueu that has to be attended to is correcting the comments in the code, to reflect the current vertion of BBC, instead of the older ones, currently mentioned.

 

-Ethan

Link to comment
Share on other sites

Ethan,

 

That code is to be commented (or removed) from your default.php (MS1)/index.php (MS2), since it was used to show the sub-categories as you usually see in a clean osCommerce 2.2 installation. The reason to comment it out is because later down the code you include the Browse by Categories module, which replaces this feature from a clean installation. How?

 

In your default.php/index.php you must add this code twice:

          <!-- DWD Contribution -> Add: Browse by Categories v2.0. !-->
         <tr>
           <td><?php $browse_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>
         </tr>
         <!-- DWD Contribution End. !-->

Please, review the included default.php/index.php in the contribution package or read thispost reply to tuca where I explained the same solution for this problem. The first time you add the previous code it is to "replace" the original code that is now commented out. The second time is to display the content box for top-level categories.

 

I hope this helps you. If not, feel free to post your questions-doubts. About your other question, what you mean about correcting code comments?

 

Thanks.

Link to comment
Share on other sites

akasharkbow,

 

I've browsed through your store, and I see you do have deeper sub-categories than level 2. Meaning, you have two top-level categories: Browse by Item and Browse by Pattern. (By the way, nice looking store, very appealing).

 

Browse by Pattern seems to only have 2nd-level categories (sub-categories), but Browse by Item has at least 3rd-level categories (sub-categories), such as Ant Bowls, Shallow Bowls, Round Oval, Triangle, and more. This presents you a problem, which I mentioned that my quick fix would not handle it properly. I don't know if that's what you mean, because I don't see your "table border = 1" as you mentioned. Also, why aren't top-level categories being displayed as sub-categories?

 

I recall you to set the configuration settings to type 'Text' + 'Bottom' + '1 per row'. Or do you have coded the 2nd include Browse by Categories to be the v2.5 release code and the 1st include Browse by Categories to be this latest quick fix code?

 

Thanks.

Link to comment
Share on other sites

Thanks for the reply. Yes, we have two main categories with sub and sub categories below them. The "Browse by Pattern" is going to end up similar to the other category except that we haven't added all the categories in yet so for now they are only what you see.

 

I am using the latest version for your code and on that one particular one, I comments or removed the code to pull out the to category image and left just the text. I can't remember how I did it but I was making minor changes and checking how appeared and as soon as it went away, I moved on to a different section.

 

You can see the table border=1 box if you look in between the categories. In this case go to the bottom below the vases categories and at the very very bottom under "Red & Lime".

 

Cheers,

 

David

Link to comment
Share on other sites

akasharkbow,

 

I still can't see the problem. Everything looks perfect, except for two things:

  • Layout of Top-Level Categories
  • Layout of Sub-Categories with Sub-Categories.

The first one, I think it would look best if you use the quick patch code with those configuration settings I mentioned. The second one requires yet another patch, to prevent displaying the sub-sub-category links, because the layout looks distorted if you have a browser window below 1024x768. For instance, if you open the favorites column in Internet Explorer, or you have the sidebar column open in Mozilla, the links wrap around. The quick fix for this link wrapping problem would be to comment out this code

        $content_box_contents[$row][$col + 1] = array('align'  => 'left',
                                                     'params' => 'class="smallText" valign="' . $arr_sub_category_mode[1] . '" width="' . $table_cell_width . '"',
                                                     //DWD Fix -> Change: Show blank table cell when category has no sub-categories.
                                                     //DWD Comment: azer Bug Request Link -> http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299469
                                                     'text'   => ($sub_category_links == '' && BRWCAT_SUBCAT_MODE != 'off') ? ' ' : $sub_category_links);
                                                     //DWD Fix End.

But remember, you're "pushing" the limits of this contribuition current release. It wasn't designed for this, although there are several practical navigation advantages in the way you want to do it.

Link to comment
Share on other sites

akasharkbow,

 

Or better yet: use the regular v2.5 release code for the 1st module include in your index.php (I see now that you use MS2). This 1st include will output the regular layout, with these configuration settings:

  • BRWCAT_ICON_MODE = 'image with caption'
  • BRWCAT_SUBCAT_MODE = 'right top'
  • BRWCAT_ICONS_PER_ROW = 2

This layout is your sub-categories layout.

 

The layout for the top-level categories should be this patch code:

<?php
/*
###############################################################################
#-----------------------------------------------------------------------------#
# Company:  DoWeDo-IT                                                         #
# Project:  Browse by Categories                                              #
# Filename: browse_categories.php                                             #
# Author:   Jos? Carlos Monteiro                                              #
#           mailto:[email protected]          Mob: +351.91.776-5726 #
#-----------------------------------------------------------------------------#
# Description: This script file is a module for osCommerce 2.2 MS1/MS2.       #
#   It's tailored for akasharkbow layout needs (top-level category browsing)  #
# where the category icon is not displayed and each sub-category is shows as  #
# an icon (image) instead of links with bullets.                              #
#                                                                             #
# Usage: Include this module from the main page.                              #
# Parameters:                                                                 #
# To-Do:                                                                      #
#                                                                             #
#-----------------------------------------------------------------------------#
# History:                                                                    #
#  VS     DATE            AUTHOR        SUMMARY                               #
# 1.00 23/Apr/2004 Jos? Carlos Monteiro Initial Source Code.                  #
#                                                                             #
#-----------------------------------------------------------------------------#
# This file is part of Browse by Categories.                                  #
#                                                                             #
# Browse by Categories is free software; you can redistribute it and/or modify#
# it under the terms of the GNU General Public License as published by        #
# the Free Software Foundation; either version 2 of the License, or any       #
# later version.                                                              #
#                                                                             #
# Browse by Categories is distributed in the hope that it will be useful,     #
# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
# GNU General Public License for more details.                                #
#                                                                             #
# You should have received a copy of the GNU General Public License           #
# along with Browse by Categories; if not, write to the Free Software         #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   #
#-----------------------------------------------------------------------------#
###############################################################################
*/

/*
*tab-width=2
*indent=2
*width=132
*/
?>

<!-- browse_categories !-->
<?php
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_BROWSE_CATEGORIES);

 //DWD Comment: Select Heading Text for Content Box based on current category.
 if ( (!isset($browse_category_id)) || ($browse_category_id == '0') ) {
   $browse_category_id = 0;
   $browse_category_heading = BOX_HEADING_BROWSE_TOP_CATEGORIES;
 } else {
   $browse_category_heading = BOX_HEADING_BROWSE_SUB_CATEGORIES;
 } // Checks to see if current category level is top or sub.

 //DWD Comment: Select all categories of current level.
 $categories_query = "select c.categories_id, cd.categories_name
                        from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                       where c.categories_id = cd.categories_id
                         and cd.language_id ='" . $languages_id . "'
                         and c.parent_id = '" . $browse_category_id . "'
                       order by c.sort_order, cd.categories_name";
 $arr_current_categories_query = tep_db_query($categories_query);

 //DWD Comment: Only show content box if there are categories at this level.
 if (tep_db_num_rows($arr_current_categories_query) > 0) {
   $content_box_contents = array();
   $content_box_contents[] = array('align' => 'left',
                                   'text'  => $browse_category_heading);

   new contentBoxHeading($content_box_contents, true, true);

   $content_box_contents = array();
   $content_box_contents[][] = array('align'  => 'left',
                                     'params' => 'class="smallText" valign="top" colspan=2"',
                                     'text'   => $content_box_text_parent);

   $row = 0;
   $col = 0;
   while ($current_categories = tep_db_fetch_array($arr_current_categories_query)) {
     $cPath_cur = tep_get_path($current_categories['categories_id']);

     //DWD Comment: Apply Category Name Case setting to current category name.
     $current_category_name = $current_categories['categories_name'];

     $table_cell_width = (100 / BRWCAT_ICONS_PER_ROW) . '%';
     $content_box_contents[$row][$col] = array('align'  => 'center',
                                               'params' => 'class="smallText" valign="top" width="' . $table_cell_width . '" colspan="2"',
                                               'text'   => '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_cur, 'NONSSL') . '"><b>' .
                                                           $current_category_name . '</b></a>');

     //DWD Comment: Select all Sub-Categories of Top-Category (Parent ID equal to Category ID).
     //DWD Comment: Sort rows by Sort Order and then Name.
     $sub_query = "select c.categories_id, cd.categories_name, c.categories_image
                     from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                    where c.categories_id = cd.categories_id
                      and cd.language_id='" . $languages_id . "'
                      and c.parent_id ='" . $current_categories['categories_id'] . "'
                    order by c.sort_order, cd.categories_name";
     $arr_sub_categories_query = tep_db_query($sub_query);

     //DWD Comment: Build Sub Category Links.
     if (tep_db_num_rows($arr_sub_categories_query) > 0) {
       $row++;
       while ($sub_categories = tep_db_fetch_array($arr_sub_categories_query)) {
         $cPath_new_sub = $cPath_cur . '_' . $sub_categories['categories_id'];
         $sub_category_links = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">' .
                                tep_image(DIR_WS_IMAGES . $sub_categories['categories_image'], $sub_category_name, SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) .
                                '<br />' . $sub_categories['categories_name'] . '</a>';

         $content_box_contents[$row][$col] = array('align'  => 'center',
                                                   'params' => 'class="smallText" valign="top" width="' . $table_cell_width . '"',
                                                   'text'   => ($sub_category_links == '' && BRWCAT_SUBCAT_MODE != 'off') ? ' ' : $sub_category_links);
         $col++;
         if ($col >= 2) {
           $row++;
           $col = 0;
         }

       } // While Loop: Fetch all Query Rows. Each row is a Sub Category of current level Category.
     } // Middle If: Build Sub Category Links if they exist.
     $row++;
     $col = 0;
   } // While Loop: Grab all current level Categories.

   new contentBox($content_box_contents);
 } // Check if there are categories at this level.
?>
<!-- browse_categories_eof !-->

This code has the layout hardcoded, without checking the configuration settings. Create a new source code file, such as browse_top_categories.php, put this code inside it and save it in /catalog/includes/modules. Then, on the 2nd module include in index.php, instead of calling include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); call instead include(DIR_WS_MODULES . 'browse_top_categories.php');.

 

Hope that this helps you out. If not, I'll keep trying to tailor the code to your needs.

 

Thanks.

Link to comment
Share on other sites

Regarding the problem I mentioned before;

(quick reminder: If I'm in a cetegory, say, Hardware, The subcategories don't appear, only the products within the top level category)

 

I compaired my index.php to the one in the contributions' ZIP file, and there's no diference.

My guess, is that the problem might be caused if a category has sub-categories, and products in the same level. In my case, for example, I may have:

Star Trek

+Shirts

+Action figures

+Posters

-Klingon snow globe

-Some other product

-And so on...

 

Where the Bold represents a sub-category, and the italic, a product.

 

I haven't seen any other stores where products and categories are listed in the same level, and this is whjy I suspect that this is the cause. I can't think of any other reason why the subcategories wouldn't be listed. I'd love some help here!

 

Could you direct me to the lines of code that call the subcategory display, within the contributions index.php?

 

-Ethan

Link to comment
Share on other sites

Ethan,

 

Depends if you're using MS1 or MS2. Here are the code lines.

For MS1, find this code on lines 115..119 of default.php:

          <!-- DWD Contribution -> Add: Browse by Categories v1.0. //-->
         <tr>
           <td><?php $browse_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>
         </tr>
         <!-- DWD Contribution End. //-->

For MS2, find the same code on lines 128..132 of index.php. This include is called at category levels other than top-level, which is usually where people forget to add the include statement and report back problems of duplicated sub-category icons. But that's another issue, and I'm here to point you out where can be a glitch.

 

Since this code only selects sub-categories, I see no reasons why you should have sub-categories and products displayed, but I may be forgetting an important field. The code, in /catalog/includes/modules/browse_categories.php, is on lines 161..167:

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

The reason why I think everything is correct is because if you go to a leaf-category (a category with only products) then the content box doesn't show up, and that's because of the code in lines 95..105:

  //DWD Comment: Select all categories of current level.
 $categories_query = "select c.categories_id, cd.categories_name, c.categories_image
                        from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                       where c.categories_id = cd.categories_id
                         and cd.language_id ='" . $languages_id . "'
                         and c.parent_id = '" . $browse_category_id . "'
                       order by c.sort_order, cd.categories_name";
 $arr_current_categories_query = tep_db_query($categories_query);

 //DWD Comment: Only show content box if there are categories at this level.
 if ((tep_db_num_rows($arr_current_categories_query) > 0) and (BRWCAT_ICON_MODE != 'off')) {

This first SQL Query checks if current category, with ID equal to $browse_category_id, has any sub-categories (c.parent_id = $browse_category_id). If that's not the case, then if following if statement bypasses the remaining code. If there are sub-categories, then the above second SQL Query grabs all sub-categories data, and only sub-categories. Or am I wrong?

 

Besides telling you this, the only think I can think of is trying to simulate your problem on my Test installation of osCommerce. I'll report back to you. Do you have an URL where I can see the problem, first?

 

Thanks.

Link to comment
Share on other sites

straider,

You could take a look at my site at http://www.madab-il.com. though the site is in Hebrew, I think you could manage, with the layout and the images.

Click on the Star Trek category (second row, on the right). you will the nsee the products I have in that category, but not the subcategories. You could only get to them by clicking on them from the categories box on the right. I'm sure I'm loosing a lot of customers because of the fact they can't find things they're looking for...

Like I said earlier, my index.php is identicle to the one in the contribution, and even tehr I can't seem to understand how it's meant to show the categories in non-leaf categories: around line 160 of the index.php file is all the code that displays products. I can't find any referance to the BBC in this segment of the code! I'd expect there to be the sub-categories box, and under that, the products listing...

Link to comment
Share on other sites

Ethan,

 

I've tried to make some sense out of viewing the page source from your site, and indeed I see the comments I was looking for:

  • <!-- DWD Contribution -> Add: Browse by Categories v2.0. !-->
    ...
    <!-- browse_categories !-->
    ...
    ...
    ...
    <!-- browse_categories_eof !-->
    ...
    <!-- DWD Contribution End. !-->

, but only on the main page.

 

This tells me that you have the 2nd include working OK, no complains here. But I can see those comments when going a category level deeper, and as such you don't get the BBC content box to display your sub-categories of current category level. Are you totally sure you add the 1st include in index.php? The fastest (easiest) explanation is that you didn't add the 1st include.

 

Your index.php must have these lines coded twice:

          <!-- DWD Contribution -> Add: Browse by Categories v1.0. //-->
        <tr>
          <td><?php $browse_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>
        </tr>
        <!-- DWD Contribution End. //-->

As I mentioned, the first time this block of lines appear has the purpose of calling BBC at category-levels deeper than top-level (the one you're trying to make it work). The second time this same block of lines appear, down the code in index.php, which you have it right, is to display the top-level categories.

 

I suggest you to use (temporarly or on your offline system if you have one) the index.php included in the contribution package. Use it and browse deeper in the categories. You will see it works fine. Then, backtrack all DWD comments on it and try to match the code in between opening and closing DWD comments with the code on your live index.php. I'm very sure your 1st include is not matching the one in index.php of this contribution. Please, pay attention to the section of lines that have to be commented out in index.php. I'm sure you did this because the default sub-category icons layout (of a clean MS2 installation) are no longer showing up on your live store. Right after these commented lines, you must add the above block of code. Please check it.

 

If that doesn't help, then post the 5 clips of your index.php with several lines before and after each block of code added by this contribution, and I'll try to match it against mine. I really don't know how to help you much more than this. You have any ideas?

 

Regards.

Link to comment
Share on other sites

Features Request for Browse by Categories v2.6:

  • Parent Category Link in Product Listing - Aims to present a more practical navigation to visitors, by providing a link to the parent category of the current category product listing. Kudos: belray.
  • Apply CSS display:inline or display:block to Sub-Category Links - Aims to allow better control over the way the sub-category links are displayed. At present, when positioned below the category icon (image/text), the sub-category links follow one another, instead of occupying a new line. Kudos: dasoccerbomb.
  • New Layout - Set BRWCAT_ICON_MODE = 'text', BRWCAT_SUBCAT_MODE ='bottom' and BRWCAT_ICONS_PER_ROW = 1. It requires new configuration settings: to control the number of sub-category icons per row and to enable/disable the content box title. Kudos: akasharkbow.
  • Fix version in code comments - Clean out outdated comments with older versions from index.php, default.php and other files in the contribution. Kudos: Ethan1701.

Looking forward to hear from you all.

Link to comment
Share on other sites

Excellent contribution, I think that this will solve my layout problems. BTW akasharkbow, you have developed a very appealing site with this contrib, congrats.

 

I have an osCommerce shop that is organized to display all the sub-categories below the second level. In this beta shop, I'd like to display the sub-categories below "Product Topic" and "Product Type" on this page . As you can see by drilling down another level, it would save the user a few clicks to get to the products via a simple ordered list of the sub-categories.

 

Can this contribution accomplish this? BTW, I am using the Simple Template System (STS), but I don't think that this will cause any problems here.

 

On another topic, would it be possible to automatically list only the categories that contain products?

 

Cheers

Edited by Johnson
Link to comment
Share on other sites

gsbe,

 

First of all, let me congratulate you on a very professional and appealing layout. 5 stars!

 

Now, by issue. Correct me if I'm wrong: you wish to display something like Browse by Categories on each Category Level deeper than top-level. At Top-Level you already have a great looking layout that drives the visitor to the right place. Then, after clicking on any of the Products -> Button you would like to present the current category level icons along with a list of their sub-categories, and therefor minimizing the number of clicks the visitor has to do to reach a leaf-category (category with only products). If this is the case, then (assuming you're using MS2) just add the 1st block that includes the module (don't add the 2nd include block), on index.php. Remeber to comment out the lines of code, to prevent duplication of functionality (default osCommerce vs Browse by Categories).

 

To only display sub-category links with product count > 0, you must replace the following code in your /catalog/includes/modules/browse_categories.php:

            //DWD Fix -> Change: Use Bullet Setting from Configuration Table.
           //DWD Comment: azer Feature Request Link -> http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299576
           $sub_category_links .= BRWCAT_SUBCAT_BULLET .
                                  ' <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">' .
                                  $sub_categories['categories_name'] . '</a>';
           //DWD Fix End.

           //DWD Comment: Spaceboy Feature Request Link -> http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=298901
           //DWD Comment: Feature Request Link -> http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299903
           if (BRWCAT_SUBCAT_COUNTS != '') {
             $products_in_category = tep_count_products_in_category($sub_categories['categories_id']);
             if ($products_in_category > 0) {
               $sub_category_links .= sprintf(' ' . BRWCAT_SUBCAT_COUNTS, $products_in_category);
             }
           }
           //DWD Fix End.

with this

            $products_in_category = tep_count_products_in_category($sub_categories['categories_id']);
           if ($products_in_category > 0) {
             //DWD Fix -> Change: Use Bullet Setting from Configuration Table.
             //DWD Comment: azer Feature Request Link -> http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299576
             $sub_category_links .= BRWCAT_SUBCAT_BULLET .
                                    ' <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">' .
                                    $sub_categories['categories_name'] . '</a>';
             //DWD Fix End.

             //DWD Comment: Spaceboy Feature Request Link -> http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=298901
             //DWD Comment: Feature Request Link -> http://www.oscommerce.com/forums/index.php?showtopic=65657&view=findpost&p=299903
             if (BRWCAT_SUBCAT_COUNTS != '') {
               $sub_category_links .= sprintf(' ' . BRWCAT_SUBCAT_COUNTS, $products_in_category);
             }
             //DWD Fix End.
           }

Does that help you out?

Link to comment
Share on other sites

straider,

I took your advise, and replacved my index.php with the one in the contribution, and still, no good.

Not only that, but the lines of code you say appear twice - only appear once.

I'm attaching the code in the contribution I downloaded. Maybe you could figure out what's going on...

BTW, do you have a site for example where branch categories appear properly? IE, showing sub-categories and products?

<?php

/*

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

 

  osCommerce, Open Source E-Commerce Solutions

  http://www.oscommerce.com

 

  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 ($cateqories_products['total'] > 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="3" cellpadding="3">

  <tr>

    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

    </table></td>

<!-- 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="0">

          <tr>

            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

          </tr>

        </table></td>

      </tr>

      <tr>

        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

      </tr>

      <tr>

        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">

          <!-- DWD Contribution -> Remove: Browse by Categories v2.2. //-->

          <!--

          <tr>

            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">

              <tr>

          //-->

          <!-- DWD Contribution End. //-->

<?php

    // DWD Contribution -> Remove: Browse by Categories v2.2.

//    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";

//      }

//    }

    // DWD Contribution End.

 

// needed for the new products module shown below

    $new_products_category_id = $current_category_id;

?>

          <!-- DWD Contribution -> Remove: Browse by Categories v2.2. !-->

          <!--

              </tr>

            </table></td>

          </tr>

          //-->

          <!-- DWD Contribution End. //-->

 

          <!-- DWD Contribution -> Add: Browse by Categories v2.0. !-->

          <tr>

            <td><?php $browse_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>

          </tr>

          <!-- DWD Contribution End. !-->

 

          <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

        $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 . "'";

      }

    }

 

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

    }

?>

            <td align="right"><?php echo tep_image(DIR_WS_IMAGES . $image, HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

          </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 class="pageHeading"><?php echo HEADING_TITLE; ?></td>

            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_default.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

          </tr>

        </table></td>

      </tr>

      <tr>

        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

      </tr>

      <tr>

        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

          <tr>

            <td class="main"><?php echo tep_customer_greeting(); ?></td>

          </tr>

          <tr>

            <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

          </tr>

          <tr>

            <td class="main"><?php echo TEXT_MAIN; ?></td>

          </tr>

          <tr>

            <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

          </tr>

 

          <!-- DWD Contribution -> Add: Browse by Categories v2.0. !-->

          <tr>

            <td><br><?php include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>

          </tr>

          <tr>

            <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

          </tr>

          <!-- DWD Contribution End. !-->

 

          <tr>

            <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>

          </tr>

<?php

    include(DIR_WS_MODULES . FILENAME_UPCOMING_PRODUCTS);

?>

        </table></td>

      </tr>

    </table></td>

<?php

  }

?>

<!-- body_text_eof //-->

    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>

<!-- right_navigation_eof //-->

    </table></td>

  </tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

for compairison, here's my index.php, with the BBC and other modifications:

<?php

/*

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

 

  osCommerce, Open Source E-Commerce Solutions

  http://www.oscommerce.com

 

  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 ($cateqories_products['total'] > 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 $page_title; ?><?php echo TITLE; ?></title>

<LINK REV="made" href="mailto:[email protected]">

<META NAME="keywords" CONTENT="מדב, מד"ב, מד"ב, il, מדע בדיוני, חנות, ישראל, פנטזיה, קניה, מסע בין כוכבים, בבילון, בבילון 5, באפי, מלחמת הכוכבים, שר הטבעות, מטריקס, פארסקייפ, קלאדה, קלינגון,  sci fi, sci-fi, science fiction,madab, madab-il, israel, store, shop, buy, fantasy, star trek, buffy, babylon, babylon 5, star wars, matrix, lord of the rings, LOTR, farscape, kladagh, klingon">

<META NAME="description" CONTENT="החנות הישראלית למוצרי מדע בדיוני ופנטזיה: אספנות מעולם אחר">

<META NAME="author" CONTENT="איתן שלו">

<META NAME="ROBOTS" CONTENT="ALL">

 

<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="3" cellpadding="3">

  <tr>

    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

    </table></td>

<!-- 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="0">

          <tr>

            <td class="pageHeading"><?php echo " " . $category['categories_name']; ?></td>

            <td class="pageHeading" align="left"><?php echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

          </tr>

        </table></td>

      </tr>

      <tr>

        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

      </tr>

      <tr>

        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">

          <!-- DWD Contribution -> Remove: Browse by Categories v2.2. //-->

          <!--

          <tr>

            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">

              <tr>

          //-->

          <!-- DWD Contribution End. //-->

<?php

    // DWD Contribution -> Remove: Browse by Categories v2.2.

//    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";

//      }

//    }

    // DWD Contribution End.

 

// needed for the new products module shown below

    $new_products_category_id = $current_category_id;

?>

          <!-- DWD Contribution -> Remove: Browse by Categories v2.2. !-->

          <!--

              </tr>

            </table></td>

          </tr>

          //-->

          <!-- DWD Contribution End. //-->

 

          <!-- DWD Contribution -> Add: Browse by Categories v2.0. !-->

          <tr>

            <td><?php $browse_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>

          </tr>

          <!-- DWD Contribution End. !-->

 

          <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>

          <tr>

            <td><br><?php include(DIR_WS_MODULES . FILENAME_DEFAULT_SPECIALS); ?></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

        $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 . "'";

      }

    }

 

    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

  $category_query1 = 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 . "'");

  $category1 = tep_db_fetch_array($category_query1);

 

if ($category1['categories_name'] != "") {echo " " . $category1['categories_name'];} else { 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'];

    }

?>

            <td align="left"><?php echo tep_image(DIR_WS_IMAGES . $image, HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

          </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_COL); ?></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">

    &n

Link to comment
Share on other sites

gsbe,

 

I forgot to mention one thing. After you replace the code you will no longer be able to show categories at level 2 that although not having any products do have sub-categories of level 3. Meaning:

  • At Top-Level, you're layout handles everything.
  • At level 1, all categories are displayed and their sub-categories that have products and only those.
  • At level 2, any category with sub-categories and without products will not be displayed. This happens because from level 1 only sub-categories with products are shown and the visitor has no way to guess that there may exist these kind of categories at this level.

This is to warn you about using this quick patch code. I don't see your catalog falling under this special scenario, but pay attention when adding more sub-categories and products.

 

Regards.

Link to comment
Share on other sites

akasharkbow,

 

Just to ask you if everything is working as you planned?

 

I've visited your store again, looks great. Did you changed much code or was it easy in the end?

 

Regards.

Link to comment
Share on other sites

Ethan,

 

As you posted, if you look at lines 76, 84, 120, 128 and 330 you will see the start of the 5 blocks of code I mentioned. The first 3 blocks, starting at lines 76, 84 and 120 are just to comment out the default sub-category links presentation from a clean osCommerce MS2 installation. Blocks starting at 128 and 330 are to include the Browse by Categories module.

 

The first one, 128, will show a content box at each category level deeper than top level (the one you're trying to track down). The second one, 330, will show a content box at top-level and only at that level, which is working fine in your case.

 

Your index.php is not complete, but the part about lines 76, 84, 120 and 128 seems OK, and since 330 is working fine, I don't know what's the problem. I'll add example products to my demo site, at http://docommerce.dowedo-it.com for you to check it out. That should also shed more light into this issue.

 

Thanks.

Link to comment
Share on other sites

Ethan et al,

 

I apologize. I never really thought much about categories with products and sub-categories. Ethan, I'll try this patch on my offline system, but in the meantime if you're in a worry to fix this issue, then replace this code:

      <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
?>

with this:

      <!-- DWD Contribution -> Add: Browse by Categories v2.0. !-->
     <tr>
       <td><br><?php include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>
     </tr>
     <!-- DWD Contribution End. !-->

     <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
?>

You can find the above code around lines 293 of a clean index.php file.

 

I don't know any side-effects of using this patch, so bare that in mind. Note: nothing like trying to simulate the problem on our osCommerce, hem? :)

 

Regards.

Link to comment
Share on other sites

Features Request for Browse by Categories v2.6:

  • Parent Category Link in Product Listing - Aims to present a more practical navigation to visitors, by providing a link to the parent category of the current category product listing. Kudos: belray.
  • Apply CSS display:inline or display:block to Sub-Category Links - Aims to allow better control over the way the sub-category links are displayed. At present, when positioned below the category icon (image/text), the sub-category links follow one another, instead of occupying a new line. Kudos: dasoccerbomb.
  • New Layout - Set BRWCAT_ICON_MODE = 'text', BRWCAT_SUBCAT_MODE ='bottom' and BRWCAT_ICONS_PER_ROW = 1. It requires new configuration settings: to control the number of sub-category icons per row and to enable/disable the content box title. Kudos: akasharkbow.
  • Fix version in code comments - Clean out outdated comments with older versions from index.php, default.php and other files in the contribution. Kudos: Ethan1701.
  • Handle Categories with Products and Sub-Categories - Must add a new include in order to present the module content box for when a category with products is not a leaf-category. Kudos: Ethan1701

Looking forward to hear from you all.

Link to comment
Share on other sites

Ethan et all,

 

It's now working, as you can see it in http://docommerce.dowedo-it.com under Category Hardware (for a limited time). Again, the full patch code to handle categories with products and sub-categories requires the following code:

      <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
?>

to be replaced with this new code:

      <!-- DWD Contribution -> Add: Browse by Categories v2.0. !-->
     <tr>
       <td><br><?php $browse_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>
     </tr>
     <!-- DWD Contribution End. !-->

     <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
?>

I forgot the set the Category ID. The code is the same for MS1 (default.php) and MS2 (index.php).

 

Thanks.

Link to comment
Share on other sites

straider-

You are really above and beyond, thank you so much for all your help! I've gotten a little closer as you can see here. I need to gain control over these fonts (separately if possible) and get this out of the box and onto the page by itself. This is really working out great!

 

BTW, a hint to other users of this contribution: I'm using the '→' character as my Sub-Category Links Bullet, I think it works pretty well!

 

Thanks again for your assistance.

 

Graham

Link to comment
Share on other sites

gsbe,

 

Glad I could be of any assistance. That's IMHO the spirit of this and other open-source communities: learn with one another to have better solutions. I never imagined Browse by Categories (BBC as Ethan calls it) would have so many people using it to improve their online shops.

 

I've already started to code v2.6, at least these latest patches are now applied. But in terms of new layouts I'm still considering the best way to do it. In fact, if you don't mind my comment, I suggest you to plan to use the akasharkbow layout at category levels deeper than top-level. In your case, I think small icons would be better, but in any case an icon would improve the visual aspect when compared to text only sub-category links. You can have 2 columns, same as akasharkbow, with Browse by Product Topic and Browse by Product Type.

 

How did you manage to insert extra <br /> to separate the sub-category links?

That could be a nice feature to add, as well.

 

Regards.

Link to comment
Share on other sites

Features Request v2.6 - Development Status:

 

The patches that have been pin-pointed by Ethan are complete. The version numbers have been removed from DWD comments and a 3rd include block has been added to handle non-leaf categories with products.

 

The remaining features are, thanks to belray, dasoccerbomb and akasharkbow: add a back link on leaf-categories, apply CSS styles to category and sub-category links and design new layouts.

 

And for this, I'd like to ask everyone for help. Does anyone have comments or suggestions on:

  • How to add/improve back link on leaf-categories?
  • What new/existing layouts could be tweaked?
  • How to apply CSS to category and sub-category links?

gsbe, controlling fonts would be easy with CSS.

 

As anyone worked on any of these or has ideas on how to do them? I'm asking this because:

  • The back link shouldn't require a content box. But Browse by Categories use content boxes.
  • New layouts will surely require more configuration settings, which must be inserted in the database. And I would have to test each one, which presents me some constraints/limitations.
  • Easiest way to use CSS is use <UL> and <LI> tags to control the appearance of each sub-category link. But what's necessary to make the icon style more flexible?

As an example of CSS improvements, having sub-category link with odd-even backgrounds would be just a matter of using a cycle variable and applying bbc-sub-cat-odd li or bbc-sub-cat-even li styles.

 

I don't have much free time at the moment, for personal and professional reasons, and as such I can't promise anything. And the development cycle would be shorten with the participation of all or some of you. So, if you have any ideas, feel free to post them here.

 

Thanks to everyone.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...