Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Expanded subcaregories... again


Denzel

Recommended Posts

Good evening out there,

 

Today I decided to change "quickly" to a expanded categories box... :rolleyes:

I have OSC 2.3.4 installed, and my bm_categories.php ist 99% orginal.

Have a look at my shop.

 

Now I've lost about three hours, by installing expansion contribs, trying

hints from google, ... but nothing works :(

 

I only want the orginal categories box to open expandet with counts and

spaces in front of subcategories (dont know the english word for that, sorry).

 

I've tryed the Categories Expanded Contrib (8384) but it doesn't do it.

Product counts doesn't work, spaces are missing.

 

The 'add after line 94' hack from forum turns categories and subs upside down :wacko:

 

Can anyone please HELP ME ! AHRG <_<

Link to comment
Share on other sites

  • 2 months later...

Sorry Im late... There was nothing special Ive just modded the Categories Expanded Contrib for my needs. 
It only works with one subcategory level and categories without products are not clickable. If you still want it, here is my 
 
bm_categories.php:

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

  class bm_categories {
    var $code = 'bm_categories';
    var $group = 'boxes';
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;

    function bm_categories() {
      $this->title = MODULE_BOXES_CATEGORIES_TITLE;
      $this->description = MODULE_BOXES_CATEGORIES_DESCRIPTION;

      if ( defined('MODULE_BOXES_CATEGORIES_STATUS') ) {
        $this->sort_order = MODULE_BOXES_CATEGORIES_SORT_ORDER;
        $this->enabled = (MODULE_BOXES_CATEGORIES_STATUS == 'True');

        $this->group = ((MODULE_BOXES_CATEGORIES_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right');
      }
    }

    function getData() {
      global $categories_string, $tree, $languages_id, $cPath, $cPath_array;

      $categories_string = '';
      $tree = array();

    	$status = tep_db_num_rows(tep_db_query('describe ' .  TABLE_CATEGORIES . ' status'));


    	$query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
    	      from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
    	      where c.categories_id = cd.categories_id";
    	// 1.3 Can't have 'where' in an if statement!
    	if ($status >0)
    		$query.= " and c.status = '1'";
    	$query.= " and cd.language_id='" . $languages_id ."'
    	      order by sort_order, cd.categories_name";

    	$categories_query = tep_db_query($query);


    	// Initiate tree traverse
    	$categories_string = '';

    	//////////
    	// Display box contents
    	//////////
    	//$info_box_contents = array();
    	$row = 0;
    	$col = 0;
    	while ($categories = tep_db_fetch_array($categories_query)) {
    		if ($categories['parent_id'] == 0)
    		{
    			$temp_cPath_array = $cPath_array;  //Johan's solution - kill the array but save it for the rest of the site
    			unset($cPath_array);

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

    			$text_subcategories = '';
    			$subcategories_query = tep_db_query($query);
    			while ($subcategories = tep_db_fetch_array($subcategories_query))
    			{

    				if ($subcategories['parent_id'] == $categories['categories_id'])
    				{

    					$cPath_new_sub = "cPath="  . $categories['categories_id'] . "_" . $subcategories['categories_id'];
    					
               	      if (SHOW_COUNTS == 'true') {
								        $products_in_category = tep_count_products_in_category($subcategories['categories_id']);
								        $den_categories_string = '';
								        if ($products_in_category > 0) {
								          $den_categories_string = ' (' . $products_in_category . ')';
									        }
								      }

    					$text_subcategories .= '<div>  <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">' . $subcategories['categories_name'] . '</a>' . $den_categories_string . '</div>';
    				} // if
    			} // While Interno
    			
				
			//BOF BUG FIX by wHiTeHaT April 2014
				/* repaired parent links */
               $cPath_parent = "cPath=" . $categories['categories_id'];
               if ($categories['parent_id'] == 0){
               	$categories_string .= '<div>';
               	      if (SHOW_COUNTS == 'true') {
								        $products_in_category = tep_count_products_in_category($categories['categories_id']);
								        $den_categories_string = '';
								        if ($products_in_category > 0) {
								          $den_categories_string = ' (' . $products_in_category . ')';
									        }
								      }
								      
								    if (tep_has_category_subcategories($categories['categories_id'])) {  
                    $categories_string .= '<b>' . $categories['categories_name'] . '</b>';
                  } else {
                    $categories_string .= '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_parent, 'NONSSL') . '"><b>' . $categories['categories_name'] . '</b></a>';
									}
								$categories_string .= $den_categories_string . '</div>';
                } else {
               /* if ever need it for something else change below to your need */
               $categories_string .= '<div><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '"><b>' . $categories['categories_name'] . '</b></a></div>';
                }
							
               $categories_string .= $text_subcategories;
			//EOF BUG FIX by wHiTeHaT April 2014
				
				unset($text_subcategories);
    			$col ++;
    			if ($col > 0)
    			{
    				$col = 0;
    				$row ++;
    			}
    			$cPath_array = $temp_cPath_array; //Re-enable the array for the rest of the code
    		}
    	}

      $data = '<div class="ui-widget infoBoxContainer">' .
              '  <div class="ui-widget-header ui-corner-top infoBoxHeading">' . MODULE_BOXES_CATEGORIES_BOX_TITLE . '</div>' .
              '  <div class="ui-widget-content ui-corner-bottom infoBoxContents">' . $categories_string . '</div>' .
              '</div>';

      return $data;
    }

    function execute() {
      global $SID, $oscTemplate;

      if ((USE_CACHE == 'true') && empty($SID)) {
        $output = tep_cache_categories_box();
      } else {
        $output = $this->getData();
      }

      $oscTemplate->addBlock($output, $this->group);
    }

    function isEnabled() {
      return $this->enabled;
    }

    function check() {
      return defined('MODULE_BOXES_CATEGORIES_STATUS');
    }

    function install() {
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Categories Module', 'MODULE_BOXES_CATEGORIES_STATUS', 'True', 'Do you want to add the module to your shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_BOXES_CATEGORIES_CONTENT_PLACEMENT', 'Left Column', 'Should the module be loaded in the left or right column?', '6', '1', 'tep_cfg_select_option(array(\'Left Column\', \'Right Column\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_BOXES_CATEGORIES_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
    }

    function remove() {
      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_BOXES_CATEGORIES_STATUS', 'MODULE_BOXES_CATEGORIES_CONTENT_PLACEMENT', 'MODULE_BOXES_CATEGORIES_SORT_ORDER');
    }
  }
?>

Good luck with this ;)

Denzel.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...