Jump to content
Sign in to follow this  
goldoi

Dynamenu in box for 2.3.1

Recommended Posts

Hello everyone,

I have finish to rewrite dynamenu for incorporate it in a box, but i need help for the encoding. I just don't arrived to generate it, i have the following error: LayersMenu Error: setMenuStructureString: empty string.Halted. I think problem is in the function execute(), because i arrived to have all the code generate below the functions, he is injected in my code source. I also have finish to create an admin panel which work for all the variables but I don't want to complex the following problem. Any idea of how solve that ?

Thanx for your help.

 

Goldoi

 

<?php
$aaa =basename(getcwd()); //if we are in admin folder, skip this part
if ($aaa !='manage') {
  //Dynamenu box for osc 2.3.1 - variables
$menu_type = 1; // 0 = Horizontal Drop-down; 1 = Vertical Flyout; 2 = Tree Menu 3 = Plain Horizontal Menu; 4 = Plain Vertical Menu
$show_dmcats_as_box = true; // display in a box = true				  
$menu_icon_width = 16; // Width of icons used in menus (does not apply to plain menus).
$menu_icon_height = 16; // Height of icons used in menus (does not apply to plain menus).
$menu_fwdarrowimg  = 'forward-arrow.png';	//forward and down arrow for drop down and fly out menu	(catalog/includes/modules/boxes/dynamenu//images)
$menu_downarrowimg = 'down-arrow.png';	  
$menu_tree_current_path = true;	//for tree menu, only display category path select by user
$menu_layer_offset = array (0,4,4); //top offset, from top border, from right border, from left border	
$GLOBALS['dm_tree_folder_icons'] = true;  // Show icons on tree menus=true
$GLOBALS['dm_tree_titleclick'] = true;	// Misc setting to make folder icon clickable to expand tree menu nodes

// Include required libraries based on menu type
require_once'includes/modules/boxes/dynamenu/lib/PHPLIB.php';
require_once'includes/modules/boxes/dynamenu/lib/layersmenu-common.inc.php';

if ($menu_type < 2) { // Setup for DHTML style menus
?>
	<script language="JavaScript" type="text/javascript">
		<!--
			<?php require_once 'includes/modules/boxes/dynamenu/libjs/layersmenu-browser_detection.js'; ?>
		// -->
	</script>
	<script language="JavaScript" type="text/javascript" src="dynamenu/libjs/layersmenu-library.js"></script>
	<script language="JavaScript" type="text/javascript" src="dynamenu/libjs/layersmenu.js"></script>
<?php
require_once 'includes/modules/boxes/dynamenu/lib/layersmenu.inc.php';
$mid = new LayersMenu($menu_layer_offset[0],$menu_layer_offset[1],$menu_layer_offset[2],1);
} elseif ($menu_type > 2) { // Setup for plain style menus
require_once 'includes/modules/boxes/dynamenu/lib/plainmenu.inc.php';
$mid = new PlainMenu();
} else {  // Setup for tree style menus
	?>
	<script language="JavaScript" type="text/javascript">
		<!--
			<?php require_once 'includes/modules/boxes/dynamenu/libjs/layersmenu-browser_detection.js'; ?>
							<?php
							   if ($menu_tree_current_path) {
									 echo "\n".'var menu_tree_current_path = true';			  
								 } else {
									 echo "\n".'var menu_tree_current_path = false';									  
								 }
							?>
	// -->
	</script>
	<script language="JavaScript" type="text/javascript" src="dynamenu/libjs/layerstreemenu-cookies.js"></script>
<?php
	require_once 'includes/modules/boxes/dynamenu/lib/treemenu.inc.php';
	$mid = new TreeMenu();
}
// Set menu config variables
//echo realpath('.');
$mid->setDirroot('./');
$mid->setLibjsdir('./includes/modules/boxes/dynamenu/libjs');
if ($menu_type !=2) {
$mid->setTpldir('./includes/modules/boxes/dynamenu/templates/');
}
$mid->setImgdir('./images/');
$mid->setImgwww('images/');
$mid->setIcondir('./images/');
$mid->setIconwww('images/');
$mid->setIconsize($menu_icon_width, $menu_icon_height);
// Generate menus
$mid->setMenuStructureString($categories_string);
$mid->parseStructureForMenu('catmenu');
switch ($menu_type) {
case 0: // Horizontal drop-down
	$mid->setDownArrowImg($menu_downarrowimg);
	$mid->setForwardArrowImg($menu_fwdarrowimg);
	$mid->setHorizontalMenuTpl('layersmenu-horizontal_menu.ihtml');						
	$mid->setSubMenuTpl('layersmenu-horiz_sub_menu.ihtml');							
		  $mid->newHorizontalMenu('catmenu');	
			$mid->printHeader();
	$categories_menu = $mid->getMenu('catmenu');
			$GLOBALS['dmfooter'] = $mid->getFooter();								
	break;
case 1:  // Vertical fly-out
	$mid->setDownArrowImg($menu_downarrowimg);
	$mid->setForwardArrowImg($menu_fwdarrowimg);
	$mid->setVerticalMenuTpl('layersmenu-vertical_menu.ihtml');				
	$mid->setSubMenuTpl('layersmenu-vert_sub_menu.ihtml');							
			$mid->newVerticalMenu('catmenu');
			$mid->printHeader();
	$categories_menu = $mid->getMenu('catmenu');
			$GLOBALS['dmfooter'] = $mid->getFooter();												
	break;
case 2:  // Tree menu
		$categories_menu = $mid->newTreeMenu('catmenu');
	break;
case 3:  // Horizontal plain menu
	$mid->setPlainMenuTpl('layersmenu-horizontal_plain_menu.ihtml');		
	$categories_menu = $mid->newHorizontalPlainMenu('catmenu');							
	break;
case 4:  // Vertical plain menu
	$mid->setPlainMenuTpl('layersmenu-plain_menu.ihtml');		
	$categories_menu = $mid->newPlainMenu('catmenu');						
	break;	  
}
}

$menu_use_titles = true; //set to true to assign title tags to each menu items
$show_full_tree = true;	// show only first categories = true else false for all
$menu_icon_file = ''; //icon preceding menu items in catalog/includes/modules/boxes/dynamenu/images directory (not for plain)
$divide_subcats = 0; //if too many subcategories, display more	
$divide_subcats_text = 'more...'; // text used in previous fonction  
$categories_string = tep_make_cat_dmlist(); // Generate the menu data output (uses configuration options above)

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

function bm_flyout() {
  $this->title = MODULE_BOXES_FLYOUT_TITLE;
  $this->description = MODULE_BOXES_FLYOUT_DESCRIPTION;
  if ( defined('MODULE_BOXES_FLYOUT_STATUS') ) {
	$this->sort_order = MODULE_BOXES_FLYOUT_SORT_ORDER;
	$this->enabled = (MODULE_BOXES_FLYOUT_STATUS == 'True');

	$this->group = ((MODULE_BOXES_FLYOUT_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right');
  }
}
//Create the root category list
function tep_make_cat_dmlist($rootcatid = 0, $maxlevel = 0){

global $cPath_array, $show_full_tree, $languages_id;

global $idname_for_menu, $cPath_array, $show_full_tree, $languages_id;

// Modify category query if not fetching all categories (limit to root cats and selected subcat tree)
	if (!$show_full_tree) {
	$parent_query	= 'AND (c.parent_id = "0"';	
			if (isset($cPath_array)) {
				$cPath_array_temp = $cPath_array;
				foreach($cPath_array_temp AS $key => $value) {
						$parent_query	.= ' OR c.parent_id = "'.$value.'"';
					}
					unset($cPath_array_temp);
			}	
	$parent_query .= ')';				
	} else {
	$parent_query	= '';	
	}		
	$result = tep_db_query('select c.categories_id, cd.categories_name, c.parent_id from ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd where c.categories_id = cd.categories_id and cd.language_id="' . (int)$languages_id .'" '.$parent_query.'order by sort_order, cd.categories_name');
	while ($row = tep_db_fetch_array($result)) {				
	$table[$row['parent_id']][$row['categories_id']] = $row['categories_name'];
}

$output .= tep_make_cat_dmbranch($rootcatid, $table, 0, $maxlevel);
return $output;

}

// Create the branches off the category list
function tep_make_cat_dmbranch($parcat, $table, $level, $maxlevel) {
global $cPath_array, $menu_use_titles, $menu_icon_file, $divide_subcats, $divide_subcats_text;
	$lvl_adjust = 1;
$list = $table[$parcat];
// Build data for menu
	while(list($key,$val) = each($list)){
			if (isset($cPath_array) && in_array($key, $cPath_array)) {
		$this_expanded = '1';
		$this_selected = 'dmselected';						
	} else {
		$this_expanded = '';
		$this_selected = '';									
		}	
	if (!$level) {
				unset($GLOBALS['cPath_set']);
					$GLOBALS['cPath_set'][0] = $key;
		$cPath_new = 'cPath=' . $key;
	} else {
					$GLOBALS['cPath_set'][$level] = $key;		
		$cPath_new = 'cPath=' . implode("_", array_slice($GLOBALS['cPath_set'], 0, ($level+1)));
					$this_subcat_count++;
	}
			if ($menu_use_titles) {
				$this_title = $val;
			} else {
				$this_title = '';				
			}				
	if (SHOW_COUNTS == 'true') {
   	 $products_in_category = tep_count_products_in_category($key);
		if ($products_in_category > 0) {
			$val .= ' (' . $products_in_category . ')';
		}
	}
			if ($this_subcat_count > $divide_subcats && $divide_subcats) {
		$output .= str_repeat(".", $level+$lvl_adjust).'|'.$divide_subcats_text.'||'.$this_title.'|'.$menu_icon_file.'|'.$this_selected.'|'.$this_expanded."\n";							
				$this_subcat_count = 1;
					$lvl_adjust ++;
			}
	$output .= str_repeat(".", $level+$lvl_adjust).'|'.$val.'|'.tep_href_link(FILENAME_DEFAULT, $cPath_new).'|'.$this_title.'|'.$menu_icon_file.'|'.$this_selected.'|'.$this_expanded."\n";							
	if ((isset($table[$key])) AND (($maxlevel > $level + 1) OR ($maxlevel == '0'))) {
		$output .= tep_make_cat_dmbranch($key,$table,$level + $lvl_adjust,$maxlevel);
	}
	} // End while loop
return $output;
}

function execute() {
  global $oscTemplate;	  
  $data = '<div class="ui-widget infoBoxContainer">' .
		  '  <div class="ui-widget-header infoBoxHeading">' . MODULE_BOXES_FLYOUT_TITLE . '</div>' .
		  '  <div class="ui-widget-content infoBoxContents">' . $categories_string . '</div>' .
		  '</div>';
	 return $data;	  
	 $oscTemplate->addBlock($data, $this->group);
}
function isEnabled() {
  return $this->enabled;
}
function check() {
  return defined('MODULE_BOXES_FLYOUT_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 Dynamenu Vertical Fly out Box', 'MODULE_BOXES_FLYOUT_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_FLYOUT_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_FLYOUT_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_FLYOUT_STATUS', 'MODULE_BOXES_FLYOUT_CONTENT_PLACEMENT', 'MODULE_BOXES_FLYOUT_SORT_ORDER');
}
 }
?>

Edited by goldoi

Share this post


Link to post
Share on other sites

Replace

' <div class="ui-widget-content infoBoxContents">' . $categories_string . '</div>' .

By

' <div class="ui-widget-content infoBoxContents">' . $categories_menu . '</div>' .

 

Must echo or return it i think.

 

And:

 

$categories_string = tep_make_cat_dmlist(); // Generate the menu data output (uses configuration options above) at the begin with others variables

Edited by goldoi

Share this post


Link to post
Share on other sites

Is there any chance Dynamenu for 2.3.1 that will be published as a contribution sometime soon? Thanks !

 

The whole base of dynamenu can be considered as outdated now, so I don't think there will be any 231 release of it

Share this post


Link to post
Share on other sites

If so can you let me know of some contribution that caches the categories menu into an array and expands the subcategories, without loading the subcategories page? (the whole page will not reload, the subcategories will simply unfold below the categories).

 

I have found several scripts that will do so for 2.2 but none for 2.3.1. I could be wrong however...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×