Location: PHPKode > scripts > osCommerce drop down menu script > oscommerce-drop-down-menu-script/udm.class.php
<?php
/**
osCommerce UDM class
Date Created: 08-03-2007
Last Modified: 08-04-2007
Author: Brandon Carlson (hide@address.com)
License: See http://www.udm4.com/licensing/
Function: To provide UDM4 dropdown menu based on osCommerce Categories
**/
class UDM {
	/* Constructor Method */
	function UDM() {
		$this->menu = "";
		$this->path = HTTP_SERVER.DIR_WS_HTTP_CATALOG;
	}
	function generate($parent=0, $language=1) {
		// Generate UDM Menu using recursion
		$sql = "
			SELECT 
				* 
			FROM 
				". TABLE_CATEGORIES . " 
			LEFT JOIN
				". TABLE_CATEGORIES_DESCRIPTION ."
			ON
				". TABLE_CATEGORIES . ".categories_id = ". TABLE_CATEGORIES_DESCRIPTION .".categories_id
			WHERE parent_id = '".$parent."'
			AND ". TABLE_CATEGORIES_DESCRIPTION .".language_id = '$language'
			";
		$rs = tep_db_query($sql);
		if(tep_db_num_rows($rs)>0) {
			if($parent==0) {
				$this->menu .= "\n<ul id='udm' class='udm'>";
			}
			else {
				$this->menu .= "\n<ul>";
			}
			while($r =  tep_db_fetch_array($rs)) {
				$this->menu .= "\n\t<li>";
				$this->menu .= "\n\t\t<a href='index.php?cPath=".$r['categories_id']."'>".$r['categories_name']."</a>";
				$this->generate($r['categories_id'],$language);
				$this->menu .= "\n\t</li>";
			}
			$this->menu .= "\n</ul>";
		}
	}
	function display() {
		//output menu
		$this->generate();
		print $this->menu;
	}
	function get_config($type) {
		//load UDM configuration files, this uses standard configuration for additional infomation
		//visit http://www.udm4.com/manual/
		if($type=="header") {
			print '
				<!-- ULTIMATE DROP DOWN MENU Version 4.42 by Brothercake -->
				<!-- http://www.udm4.com/ -->
				<script type="text/javascript" src="'.$this->path.'udm-resources/udm-custom.js"></script>
				<script type="text/javascript" src="'.$this->path.'udm-resources/udm-control.js"></script>
				<script type="text/javascript" src="'.$this->path.'udm-resources/udm-style.js"></script>
			';
		}
		if($type=="body") {
			print '
				<!-- menu script -->
				<script type="text/javascript" src="'.$this->path.'udm-resources/udm-dom.js"></script>
				<!-- keyboard navigation module -->
				<script type="text/javascript" src="'.$this->path.'udm-resources/udm-mod-keyboard.js"></script>
			';		
		}
	}
}
?>
Return current item: osCommerce drop down menu script