I had this running on an old site, running: osC-BS (pre-gold, pre-frozen) and PHP 5.x. The old site did use an older version of jquery (1.11.1.min.js, if that matters).
I am now trying to update it for Phoenix 1.0.3.0 (yes, it's old too), and PHP 7.4.
Here is the code for the Categories Box:
Code: Select all
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2014 osCommerce
Released under the GNU General Public License
*/
class bm_expanding_categories {
var $code = 'bm_expanding_categories';
var $group = 'boxes';
var $title;
var $description;
var $sort_order;
var $enabled = false;
function __construct() {
$this->title = MODULE_BOXES_EXPANDING_CATEGORIES_TITLE;
$this->description = MODULE_BOXES_EXPANDING_CATEGORIES_DESCRIPTION;
if ( defined('MODULE_BOXES_EXPANDING_CATEGORIES_STATUS') ) {
$this->sort_order = MODULE_BOXES_EXPANDING_CATEGORIES_SORT_ORDER;
$this->enabled = (MODULE_BOXES_EXPANDING_CATEGORIES_STATUS == 'True');
$this->group = ((MODULE_BOXES_EXPANDING_CATEGORIES_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right');
}
}
function execute() {
global $oscTemplate, $cPath, $PHP_SELF;
$OSCOM_CategoryTree = new category_tree();
$OSCOM_CategoryTree->setCategoryPath($cPath, '<strong>', '</strong>');
$OSCOM_CategoryTree->setSpacerString(' ', 1);
$OSCOM_CategoryTree->setParentGroupString('<ul class="nav nav-list">', '</ul>', true);
$data = '<div id="Categories" class="panel panel-default no-border hidden-xs hidden-sm">' .
' <div class="panel-body ContentBody">' .
' <div class="clearfix"></div>' .
' <ul class="navMain nav-list">';
$data .= ' <li> ' .
' <div>' .
' <a href="" class="switch">';
if(!empty($cPath)) {
$data .= ' <span class="fa fa-plus-circle fa-minus-circle">' ;
$data .= ' </span> Products ' .
' </a>' .
' </div>' .
' <div class="clearfix"></div>';
$data .= ' <ul class="navMain nav-list collapse in">';
} else {
$data .= ' <span class="fa fa-plus-circle '.($sm==1?'fa-minus-circle':''). ' ">' ;
$data .= ' </span> Products ' .
' </a>' .
' </div>' .
' <div class="clearfix"></div>';
$data .= ' <ul class="navMain nav-list collapse '.($sm==1?'in':''). ' ">';
}
$data .= ' <div>' .
' <div class="panel-body ContentBody">' . tep_show_tree_box() . '</div>' .
' </div>';
$data .= ' </ul>' .
' </li>' .
' </ul>' .
' </div>' .
'</div>';
$oscTemplate->addBlock($data, $this->group);
}
function isEnabled() {
return $this->enabled;
}
function check() {
return defined('MODULE_BOXES_EXPANDING_CATEGORIES_STATUS');
}
function install() {
tep_db_query("insert into CONFIGURATION (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Categories Module', 'MODULE_BOXES_EXPANDING_CATEGORIES_STATUS', 'True', 'Do you want to add the Expanding Categories module to your shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
tep_db_query("insert into CONFIGURATION (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_BOXES_EXPANDING_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 CONFIGURATION (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_BOXES_EXPANDING_CATEGORIES_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
}
function remove() {
tep_db_query("delete from CONFIGURATION where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
function keys() {
return array('MODULE_BOXES_EXPANDING_CATEGORIES_STATUS',
'MODULE_BOXES_EXPANDING_CATEGORIES_CONTENT_PLACEMENT',
'MODULE_BOXES_EXPANDING_CATEGORIES_SORT_ORDER');
}
}
This does call a new function called tep_show_tree_box(), which does generate an expanded categories list (I can post that too, if it helps)
My problem is that the menu does not expand (and later collapse) at all. Inspecting the code shows that the full menu tree is there, and a .collapse:not(.show) is toggled, preventing the menu from expanding.
I don't know if this a problem with Bootstrap, jQuery, PHP, or what.
Any help would be greatly appreciated!
Malcolm