Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Browse by Categories


Guest

Recommended Posts

THANX FOR THE CONTRIBUTION. It works fine in my shop. Thanx a million times guys. But i got 1 request. I have a problem, because mine product_info page doesn't have any link to other categories. So i thought maybe i can put this into the product_info page.

 

 

When i put the code like this it DOES work:

 

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

<tr>

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

</tr>

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

 

When i put the code like this it DOES NOT work:

 

<!-- DWD Modify -> Add: Handle Non Leaf with Products.

<!-- DWD Comment: Ethan1701 Feature Request Link -> http://www.oscommerce.com/forums/index.php?sho...st&p=352498

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

<tr>

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

</tr>

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

 

 

What i want is to put the current sub-categories into the product_info page.

Is there a little code for this?

Edited by Alexian
Link to comment
Share on other sites

  • 1 month later...
  • Replies 190
  • Created
  • Last Reply

Top Posters In This Topic

This contribution works great. I'm wondering if it would be possible to make it so only the first 4 or 5 subcategories are displayed followed by a link that says "more" or something similar and clicking that link takes you to the subcategory page showing all of our subcategories. This will make it look better visually when you have lots of subcategories.

 

Backcountry.com has basically what I'm looking for.

Edited by rkoechel2004

rkoechel2004

Link to comment
Share on other sites

  • 3 weeks later...

Hello!

Thank You for Your contribution!

 

I have a small question.

Howe can i change for smaller distance between showing categories and sub-ctaregories? I am searching, trying, but i can no find it.

 

ah, my small sugestion. In last archiwe in contribution repozitory, there is a wrong name. In catalog\includes\modules there is "osc_browse_categories.php"

and it should be "browse_categories.php" and somebody can have a problems with that (file not found) e.g. me :) but i solved it.

 

Thanks in advance

 

 

p.s. sorry for my english

Link to comment
Share on other sites

  • 3 months later...
  • 1 year later...

I did install browse by categories in a test store. Tried looking at demo but get a 404 error by entering demo link.

 

Not much to contribution. upload a few files, edit three files and run the sql code. But my admin -> configuration -> browse by category is not like your sample images.

 

Here is what is in the download:

admin-view-1.jpg

 

This is mine:

admin_image.jpg

 

So you can see, I am not able to enable it.

Link to comment
Share on other sites

Hi I got this working Kinda. I have a Modified store in production. I have tried this on a new test store and works lust fine. So I figure it is what ever mods I have going. Ok here is what is happening the primary category is showing the picture but not the text. Yes I do have the text and picture enabled in the admin. It shows the text on the sub-categories. and on that topic it only shows the first sub-categories not the 2nd sub-categories. any Ideas where I should be looking?

Link to comment
Share on other sites

Hello i have added to the code to caching this module you can find it in the Brows by categories contribution section

 

you need Browse by Categories 2.7 already installed

 

 

In /catalog/includes/functions/cache.php

 

add the following before the closing end ?> tag

 

////
//! Cache the browse categories module

// Cache the browse categories module


function tep_cache_browse_categories($auto_expire = false, $refresh = false) {



global $cPath, $language, $languages_id, $tree, $cPath_array, $categories_string;



  $cache_output = '';

if (($refresh == true) || !read_cache($cache_output, 'browse_categories_box-' . $language . '.cache' . $cPath, $auto_expire)) {
       ob_start();

include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES);

   $cache_output = ob_get_contents();

 ob_end_clean();

write_cache($cache_output, 'browse_categories-' . $language . '.cache' . $cPath);
   }


return $cache_output;

}

 

In /catalog/index.php

 

 

find all

include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); 

replace with

 

if ((USE_CACHE == 'true') && empty($SID)) {

echo tep_cache_browse_categories();

} else {

include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES);

}

Link to comment
Share on other sites

  • 10 months later...
  • 2 months later...

I have modified browse_categories.php to the following and it works now on 2.3.1.

 

Let me know if it works also for you guys:

 

<?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 is used to display a content box with current level categories and     #
# their sub-categories. The current level categories can be shown as images   #
# or as text, while sub-categories when shown are always as text.             #
#   The settings are configured through the osCommerce Administration, under  #
# Configuration section.                                                      #
#                                                                             #
# Usage: Include this module from the main page.                              #
# Parameters:                                                                 #
#   BRWCAT_ICON_MODE                                                          #
#   BRWCAT_SUBCAT_MODE                                                        #
#   BRWCAT_ICONS_PER_ROW                                                      #
#   BRWCAT_SUBCAT_BULLET                                                      #
#   BRWCAT_SUBCAT_COUNTS                                                      #
#   BRWCAT_NAME_CASE                                                          #
#                                                                             #
# To-Do:                                                                      #
#   Apply UL and LI elements to Sub Category Links, using CSS styles.         #
#                                                                             #
#-----------------------------------------------------------------------------#
# History:                                                                    #
#  VS     DATE            AUTHOR        SUMMARY                               #
# 1.00 12/Nov/2003 José Carlos Monteiro Initial Source Code.                  #
# 2.00 19/Jan/2004 José Carlos Monteiro Make it 2.2-MS2 compatible.           #
# 2.10 21/Jan/2004 José Carlos Monteiro Add GPL License File.                 #
#                                       Add GPL copying permission statement. #
#                                       Add POSITION_SUB_CATEGORIES.          #
#                                       Replace hard-coded table with         #
#                                         odd and even rows or columns.       #
# 2.20 21/Jan/2004 José Carlos Monteiro Remove original sub category icons.   #
# 2.31 27/Jan/2004 Didier Debbaut (DDB) Add sub categories products count.    #
# 2.40 29/Jan/2004 José Carlos Monteiro Add new settings to configuration.    #
#                                       Use BULLET_BROWSE_SUB_CATEGORIES.     #
#                                       Use DISPLAY_SUB_CATEGORIES_COUNT.     #
#                                       Show blank table cell when empty sub. #
#                                       Browse to parent category link.       #
#                                       Set correct breadcrum trail cPath.    #
#                                       Clear Sub-Categories Link.            #
#                                       Replace $cPath with $cPath_cur.       #
# 2.50 03/Fev/2004 José Carlos Monteiro Use Uniform variables Naming Scheme.  #
#                                       Add BRWCAT_NAME_CASE.                 #
#                                       Choose Image with or without caption. #
#      08/Fev/2004 azer                 Fix blank cell, image wo caption bugs.#
#      08/Fev/2004 José Carlos Monteiro Use Language Dependant files.         #
# 2.60 28/Apr/2004 José Carlos Monteiro Remove Version from Comments.         #
#                                       Handle Non-Leaf with Products.        #
#                                       Cleanup Bug/Feature Tracking Comments.#
#                                       Moved Language files to modules/.     #
#                                                                             #
#-----------------------------------------------------------------------------#
# 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
 //DWD GOTCHA: /modules/ is hardcoded, but should be the same value as the value in configuration.php
 require(DIR_WS_LANGUAGES . $language . '/modules/' . 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 Comment: Browse to parent category link from 3rd level categories to 2nd level category.
     $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>';
   } else if ($browse_category_id > 0) {
     //DWD Comment: Browse to top-level category link.
     $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.
   }

   //DWD Comment: Create Content Box with Heading Text.
   $content_box_contents = array();
   $content_box_contents[] = array('align' => 'left',
                                   'text'  => $browse_category_heading);


   //DWD Comment: Display Browse to ... Link.
   $content_box_contents = array();
   $content_box_contents[][] = array('align'  => 'left',
                                     'params' => 'class="smallText" valign="top" colspan=2"',
                                     'text'   => '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_cur, 'NONSSL') . '"><b>' . $current_category_name . '</b></a>');


?>
 <div class="ui-widget infoBoxContainer">
   <div class="ui-widget-header ui-corner-top infoBoxHeading">
     <span><?php echo $browse_category_heading; ?></span>
   </div>
 </div>
<?php




   //DWD Comment: Initialize Content Box Row/Column Variables and Loop through all current categories.
   $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 = '';
       if (tep_db_num_rows($arr_sub_categories_query) > 0) {
         $sub_category_links .= '<ul class="BrowseBy">';
         while ($sub_categories = tep_db_fetch_array($arr_sub_categories_query)) {
           $cPath_new_sub = $cPath_cur . '_' . $sub_categories['categories_id'];
           $sub_category_links .= '<li class="BrowseBy">' . BRWCAT_SUBCAT_BULLET .
                                  '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">' .
                                  $sub_categories['categories_name'] . '</a>';

           //DWD Comment: Display Sub-Category Product Count, if enabled.
           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);
             }
           }

           $sub_category_links .= '';

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

     //DWD Comment: Set Content Box Table Width depending on Sub-Category Link Mode.
     if ($arr_sub_category_mode[0] == 'right') {
       $table_cell_width = (100 / BRWCAT_ICONS_PER_ROW / 2) . '%';
     } else {
       $table_cell_width = (100 / BRWCAT_ICONS_PER_ROW) . '%';
     }

     //DWD Comment: Fill Content Box Array with Category Icon.
     //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.
     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 . $current_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.

     //DWD Comment: Fill Content Box Array with Sub-Category Links.
     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 . '"',
                                                     'text'   => ($sub_category_links == '' && BRWCAT_SUBCAT_MODE != 'off') ? ' ' : $sub_category_links);
       $col = $col + 2;
       if ($col >= BRWCAT_ICONS_PER_ROW * 2) {
         $col = 0;
         $row++;
       }
     } else {
       $content_box_contents[$row + 1][$col] = array('align'  => 'left',
                                                     'params' => 'class="smallText" valign="top" width="' . $table_cell_width . '"',
                                                     'text'   => ($sub_category_links == '' && BRWCAT_SUBCAT_MODE != 'off') ? ' ' : $sub_category_links);
       $col++;
       if ($col >= BRWCAT_ICONS_PER_ROW) {
         $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

  • 2 weeks later...
  • 2 months later...

At first: Thanks for this great contrib and working out the 2.3.1 adaption!

 

I only have a really small issue driving me up the wall since yesterday: Where can I modify the backgroud color of the box (around the categories images). I tried in stylesheet.css as well as in the file (.../modules/browse_categories.php) itself. No chance. But there must be a way and it can't be very difficult (shame).

 

Arved

Link to comment
Share on other sites

Solved! I mean the Browse Categories box background color issue I was talking of in my last post ...

 

For anyone who needs it one day: Change IS done in the stylesheet.css:

 

.infoBox {

background: #b6b7cb;

 

Arved

Link to comment
Share on other sites

  • 2 weeks later...

The 2.31 code with the BR tag closed properly as in

 <br /> 

sorry I hate to correct other's work, but I do like it to pass the W3C validator check for xhtml !

 

<?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 is used to display a content box with current level categories and     #
# their sub-categories. The current level categories can be shown as images   #
# or as text, while sub-categories when shown are always as text.             #
#   The settings are configured through the osCommerce Administration, under  #
# Configuration section.                                                      #
#                                                                             #
# Usage: Include this module from the main page.                              #
# Parameters:                                                                 #
#   BRWCAT_ICON_MODE                                                          #
#   BRWCAT_SUBCAT_MODE                                                        #
#   BRWCAT_ICONS_PER_ROW                                                      #
#   BRWCAT_SUBCAT_BULLET                                                      #
#   BRWCAT_SUBCAT_COUNTS                                                      #
#   BRWCAT_NAME_CASE                                                          #
#                                                                             #
# To-Do:                                                                      #
#   Apply UL and LI elements to Sub Category Links, using CSS styles.         #
#                                                                             #
#-----------------------------------------------------------------------------#
# History:                                                                    #
#  VS     DATE            AUTHOR        SUMMARY                               #
# 1.00 12/Nov/2003 José Carlos Monteiro Initial Source Code.                  #
# 2.00 19/Jan/2004 José Carlos Monteiro Make it 2.2-MS2 compatible.           #
# 2.10 21/Jan/2004 José Carlos Monteiro Add GPL License File.                 #
#                                       Add GPL copying permission statement. #
#                                       Add POSITION_SUB_CATEGORIES.          #
#                                       Replace hard-coded table with         #
#                                         odd and even rows or columns.       #
# 2.20 21/Jan/2004 José Carlos Monteiro Remove original sub category icons.   #
# 2.31 27/Jan/2004 Didier Debbaut (DDB) Add sub categories products count.    #
# 2.40 29/Jan/2004 José Carlos Monteiro Add new settings to configuration.    #
#                                       Use BULLET_BROWSE_SUB_CATEGORIES.     #
#                                       Use DISPLAY_SUB_CATEGORIES_COUNT.     #
#                                       Show blank table cell when empty sub. #
#                                       Browse to parent category link.       #
#                                       Set correct breadcrum trail cPath.    #
#                                       Clear Sub-Categories Link.            #
#                                       Replace $cPath with $cPath_cur.       #
# 2.50 03/Fev/2004 José Carlos Monteiro Use Uniform variables Naming Scheme.  #
#                                       Add BRWCAT_NAME_CASE.                 #
#                                       Choose Image with or without caption. #
#      08/Fev/2004 azer                 Fix blank cell, image wo caption bugs.#
#      08/Fev/2004 José Carlos Monteiro Use Language Dependant files.         #
# 2.60 28/Apr/2004 José Carlos Monteiro Remove Version from Comments.         #
#                                       Handle Non-Leaf with Products.        #
#                                       Cleanup Bug/Feature Tracking Comments.#
#                                       Moved Language files to modules/.     #
#                                                                             #
#-----------------------------------------------------------------------------#
# 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
 //DWD GOTCHA: /modules/ is hardcoded, but should be the same value as the value in configuration.php
 require(DIR_WS_LANGUAGES . $language . '/modules/' . 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 Comment: Browse to parent category link from 3rd level categories to 2nd level category.
     $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>';
   } else if ($browse_category_id > 0) {
     //DWD Comment: Browse to top-level category link.
     $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.
   }

   //DWD Comment: Create Content Box with Heading Text.
   $content_box_contents = array();
   $content_box_contents[] = array('align' => 'left',
                                   'text'  => $browse_category_heading);


   //DWD Comment: Display Browse to ... Link.
   $content_box_contents = array();
   $content_box_contents[][] = array('align'  => 'left',
                                     'params' => 'class="smallText" valign="top" colspan=2"',
                                     'text'   => '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_cur, 'NONSSL') . '"><b>' . $current_category_name . '</b></a>');


?>
 <div class="ui-widget infoBoxContainer">
   <div class="ui-widget-header ui-corner-top infoBoxHeading">
     <span><?php echo $browse_category_heading; ?></span>
   </div>
 </div>
<?php




   //DWD Comment: Initialize Content Box Row/Column Variables and Loop through all current categories.
   $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 = '';
       if (tep_db_num_rows($arr_sub_categories_query) > 0) {
         $sub_category_links .= '<ul class="BrowseBy">';
         while ($sub_categories = tep_db_fetch_array($arr_sub_categories_query)) {
           $cPath_new_sub = $cPath_cur . '_' . $sub_categories['categories_id'];
           $sub_category_links .= '<li class="BrowseBy">' . BRWCAT_SUBCAT_BULLET .
                                  '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">' .
                                  $sub_categories['categories_name'] . '</a>';

           //DWD Comment: Display Sub-Category Product Count, if enabled.
           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);
             }
           }

           $sub_category_links .= '';

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

     //DWD Comment: Set Content Box Table Width depending on Sub-Category Link Mode.
     if ($arr_sub_category_mode[0] == 'right') {
       $table_cell_width = (100 / BRWCAT_ICONS_PER_ROW / 2) . '%';
     } else {
       $table_cell_width = (100 / BRWCAT_ICONS_PER_ROW) . '%';
     }

     //DWD Comment: Fill Content Box Array with Category Icon.
     //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.
     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 . $current_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.

     //DWD Comment: Fill Content Box Array with Sub-Category Links.
     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 . '"',
                                                     'text'   => ($sub_category_links == '' && BRWCAT_SUBCAT_MODE != 'off') ? ' ' : $sub_category_links);
       $col = $col + 2;
       if ($col >= BRWCAT_ICONS_PER_ROW * 2) {
         $col = 0;
         $row++;
       }
     } else {
       $content_box_contents[$row + 1][$col] = array('align'  => 'left',
                                                     'params' => 'class="smallText" valign="top" width="' . $table_cell_width . '"',
                                                     'text'   => ($sub_category_links == '' && BRWCAT_SUBCAT_MODE != 'off') ? ' ' : $sub_category_links);
       $col++;
       if ($col >= BRWCAT_ICONS_PER_ROW) {
         $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

Hi,

 

I've installed this add on as it's exactly what I wanted for my homepage. However I'm having a few problems I can't seem to fix.

 

Firstly, here's my site.

 

1: As you'll see, I've changed the BOX_HEADING_BROWSE_TOP_CATEGORIES to an image rather than a string. My problem is that this element goes beyond the right hand side of my container. I've tried changing the margins, width etc, even when it was text, and I can't get the overlap to go away.

 

2: I'm getting the name of all categories below the category images adding a category after each one, I only want the individual category name associated with the category image above.

 

3: Is it possible to have the image go opaque:0.5 on hover, without the text doing so too? Putting this in the img a:hover style didn't have any effect.

 

4: Is it possible to put an equivalent of BOX_HEADING_BROWSE_TOP_CATEGORIES below the categories? I want to put another image, much like the BOX_HEADING_BROWSE_TOP_CATEGORIES below my categories.

 

Sorry for all of the questions, I thought it best to put them in one post, rather than filling up the thread.

 

Many thanks

Link to comment
Share on other sites

  • 1 year later...

hello, i have intalled the module before on a 2.3.1 and it worked fine.

now i'm intalling it on a 2.3.3 version but it give me this error on the main page:

 

Fatal error: Class 'contentBox' not found in /home/wood/public_html/includes/modules/browse_categories.php on line 166

 

any idea ?

 

Thanks

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