Version: 0.4
Type: Full Script
Category: HTML
License: GNU General Public License
Description: PHP code that generates a DHTML Drop Down Men. See http://www.steo.it/phpddm for demo.
PHP Drop Down Menu 0.4 (07-NOV-2001) by Stefano SteO Arcidiacono (www.steo.it/php)
Split this text into three files, then configure it and include in your site.
(see http://www.steo.it/php for demo and zip files download)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++ File "phpddm.css"
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/* MAIN MENU SETTINGS*/
.MENU {
font-family : Verdana;
font-size : 12px;
text-decoration: none;
color: Black;
}
/* VERTICAL WORD*/
.VMENU {
font-family : Verdana;
font-size : 10px;
text-decoration: none;
color: Black;
}
/* SUBMENU SETTINGS */
.SUBMENU {
font-family : Verdana;
font-size : 10px;
color : Black;
text-decoration: none;
}
/* SUBMENU SETTINGS FOR OPERA, IE6 */
A.SUBMENU {
font-family : Verdana;
font-size : 10px ;
text-decoration : none ;
width : 100% ;
color : black ; }
A.SUBMENU:hover {
background-color : Silver;
color : Black;
}
A.SUBMENU:visited { color : black ; }
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++ File "phpddm.inc.php"
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<?
###############################################################################
# - SteO Menu - Ver. 0.4php (07-NOV-01) [http://www.steo.it/php]
#
# Please give me any comment !
#
# Copyright (c) 2001, Stefano SteO Arcidiacono - info@steo.it.
#
# This file is distributed with General Public License.
# Any derivatives of this software must remain OpenSource and
# must be distributed at no charge.
# (See license.txt for additional information)
#
###############################################################################
// Edit this file to configure PHP Drop Down Menu
# menu distance from top
$phpddm_top = "0";
# submenu distance from top
$phpddm_subtop = "20";
# submenu width
$phpddm_width = "100";
# menu color
$phpddm_mcolor = "#C0C0C0";
# menu over color
$phpddm_mover = "#8C8C8C";
# submenu background color
$phpddm_scolor = "#FFFFFF";
# submenu over color
$phpddm_sover = "#C0C0C0";
# submenu background layer color (== submenu borders)
$phpddm_lcolor = "#000000";
# menu(TITLE, VTITLE, WIDTH, URL, TARGET)
#
# submenu(TITLE, URL, TARGET)
$menu[0] = new menu("Item one", "MENU 1", "100", "#", "");
$submenu[0][0] = new submenu("Link 1", "#", "");
$submenu[0][1] = new submenu("Link 2", "#", "");
$submenu[0][2] = new submenu("Link 3", "#", "");
$submenu[0][3] = new submenu(" ", "#", "");
$submenu[0][4] = new submenu("Blank Target", "index.php", "_blank");
$submenu[0][5] = new submenu("Link 2", "#", "");
$submenu[0][6] = new submenu("Link 3", "#", "");
$menu[1] = new menu("Item two", "MENU 2", "100", "#", "");
$submenu[1][0] = new submenu("Link 1", "#", "");
$submenu[1][1] = new submenu("Link 2", "#", "");
$submenu[1][2] = new submenu("Link 3", "#", "");
$submenu[1][3] = new submenu(" ", "#", "");
$submenu[1][4] = new submenu("Link 1", "#", "");
$submenu[1][5] = new submenu("Link 2", "#", "");
$submenu[1][6] = new submenu("Link 3", "#", "");
$menu[2] = new menu("Item three", "MENU 3", "100", "#", "");
$submenu[2][0] = new submenu("Link 1", "#", "");
$submenu[2][1] = new submenu("Link 2", "#", "");
$submenu[2][2] = new submenu("Link 3", "#", "");
$submenu[2][3] = new submenu(" ", "#", "");
$submenu[2][4] = new submenu("Link 1", "#", "");
$submenu[2][5] = new submenu("Link 2", "#", "");
$submenu[2][6] = new submenu("Link 3", "#", "");
$menu[3] = new menu("Empty Item ", "", "100", "index.php", "_blank");
$menu[4] = new menu("Item Five", "MENU 4", "100", "#", "");
$submenu[4][0] = new submenu("Link 1", "#", "");
$submenu[4][1] = new submenu("Link 2", "#", "");
$submenu[4][2] = new submenu("Link 3", "#", "");
$submenu[4][3] = new submenu(" ", "#", "");
$submenu[4][4] = new submenu("Link 1", "#", "");
$submenu[4][5] = new submenu("Link 2", "#", "");
$submenu[4][6] = new submenu("Link 3", "#", "");
?>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++ File "phpddm.php"
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<?
###############################################################################
# - SteO Menu - Ver. 0.4php (07-NOV-01) [http://www.steo.it/php]
#
# Please give me any comment !
#
# Copyright (c) 2001, Stefano SteO Arcidiacono - info@steo.it.
#
# This file is distributed with General Public License.
# Any derivatives of this software must remain OpenSource and
# must be distributed at no charge.
# (See license.txt for additional information)
#
###############################################################################
//
// >>> You don't need to edit this file <<<
//
echo "<!-- PHP Drop Down Menu 0.4 by Stefano SteO Arcidiacono (ww.steo.it/php) -->\n";
class menu {
function menu($title, $vtitle, $width, $url, $target) {
$this->TITLE = $title;
$this->VTITLE = $vtitle;
$this->WIDTH = $width;
$this->URL = $url;
$this->TARGET = $target;
}
}
class submenu {
function submenu($title, $url, $target) {
$this->TITLE = $title;
$this->URL = $url;
$this->TARGET = $target;
}
}
include("phpddm.inc.php");
// Browser check 2.0
unset($browser);
$browserie = false;
if (strstr(strtolower($HTTP_USER_AGENT), "opera")) { $browser = "op"; }
elseif (strstr(strtolower($HTTP_USER_AGENT), "msie")) { $browser = "ie"; }
elseif (strstr(strtolower($HTTP_USER_AGENT), "mozilla")) { $browser = "ns"; if (strstr(strtolower($HTTP_USER_AGENT), "6")) $browser = "ns6"; }
$Maxmenu = count($menu) - 1;
$somma = "0";
for ($i=0; $i<=$Maxmenu; $i++ ) {
$menu_width[$i] = $menu[$i]->WIDTH;
$menu_pos[$i] = $somma;
$somma = $somma + $menu_width[$i];
}
function vtitle($str) {
$return = "";
for ($i=0; $i<=strlen($str); $i++ ) { $return.= (substr($str, $i, 1)."<br>"); }
return $return;
}
########################## Create main menu
unset($str);
$str = "";
$str.= "<div id=\"phpddmMenu\" style=\"position:absolute; width:100%; top:$phpddm_top; left:0; visibility:hidden;\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr bgcolor=\"$phpddm_mcolor\">";
for ($i=0; $i<=$Maxmenu; $i++ ) {
if ($browser == "ns") {
$str.= "<td width=\"".$menu_width[$i]."\" align=\"left\"><ILAYER><LAYER width=\"".$menu_width[$i]."\" onmouseover=\"showMenu('".$i."'); bgColor='".$phpddm_mover."'\" onmouseout=\"bgColor='".$phpddm_mcolor."'\"><a href=\"".$menu[$i]->URL."\" target=\"".$menu[$i]->TARGET."\"><span class=\"MENU\">".$menu[$i]->TITLE."</span></a></LAYER></ILAYER></td>"; }
else {
$str.= "<td bgcolor=\"".$phpddm_mcolor."\" width=\"".$menu_width[$i]."\" onmouseover=\"bgColor='".$phpddm_mover."'; showMenu(".$i.")\" onmouseout=\"bgColor='".$phpddm_mcolor."'\" align=\"left\"><a href=\"".$menu[$i]->URL."\" target=\"".$menu[$i]->TARGET."\"><span class=\"MENU\">".$menu[$i]->TITLE."</span></a></td>";
}
}
if ($browser == "ns") { $str .= "<td width=\"100%\"> </td></tr></table></div>\n"; }
else { $str .= "<td> </td></tr></table></div>\n"; }
echo $str;
######################## Create Submenu
// IE and NS version
$str = "";
for ($i=0; $i<=$Maxmenu; $i++) {
//<P>echo count($submenu[$i]);
if (empty($submenu[$i])) {
$str .= "<div id=\"subMenu$i\" style=\"position:absolute; width:0; height:0; top:0; left:0; visibility:hidden; z-index:99;\"></div>";
} else {
$str .= "<div id=\"subMenu$i\" style=\"position:absolute; left:".$menu_pos[$i]."; top:$phpddm_subtop; width:$phpddm_width; background-color:black;layer-background-color:black; visibility:hidden; z-index:99;\">";
if ($browser == "ns") {
$str .= "<table width=\"$phpddm_width\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
$str .= "<tr><td valign=\"top\">";
} else {
$str .= "<table width=\"$phpddm_width\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
$str .= "<tr><td width=\"15\" bgcolor=\"#C0C0C0\" align=\"center\" valign=\"top\" style=\"padding:0,0,0,0;border-color:black;border-style:solid; border-right:0;border-width:1\"><span class=\"VMENU\">".vtitle($menu[$i]->VTITLE)."</span></td><td valign=\"top\">";
}
$str .= "<table bgcolor=\"$phpddm_lcolor\" border=\"0\" width=\"100%\" cellspacing=\"1\" cellpadding=\"1\">";
for ($k=0; $k<count($submenu[$i]); $k++) {
if ($browser == "ns") {
$str .= "<tr><td bgcolor=".$phpddm_scolor."><ILAYER><LAYER width=\"100%\" onmouseover=\"bgColor='".$phpddm_sover."'\" onmouseout=\"bgColor='".$phpddm_scolor."'\"><a href=\"".$submenu[$i][$k]->URL."\" target=\"".$submenu[$i][$k]->TARGET."\" class=\"SUBMENU\">".$submenu[$i][$k]->TITLE."</a></LAYER></ILAYER></td></tr>";
}
else {
$str .= "<tr><td bgcolor=".$phpddm_scolor." onmouseover=\"bgColor='".$phpddm_sover."'\" onmouseout=\"bgColor='".$phpddm_scolor."'\"><a href=\"".$submenu[$i][$k]->URL."\" target=\"".$submenu[$i][$k]->TARGET."\" class=\"SUBMENU\">".$submenu[$i][$k]->TITLE."</a></td></tr>"; }
}
$str .= "</table></td></tr></table></div>\n";
}
}
echo $str;
############################ Javascript #############################
?>
<script language="JavaScript">
var sub_top = <?=$phpddm_top;?>;
var x = 0; var y = 0;
var x1 = 0; var y1 = 0;
var x2 = 0; var y2 = 0;
var sel = 0; var temp;
<?
//######################## OPERA
if ($browser == "op") {
for ($i=0; $i<=$Maxmenu; $i++) {
echo "document.all['subMenu$i'].onmouseover=handlerMM;";
echo "document.all['subMenu$i'].onmouseout=handlerMM;";
}
?>
function handlerMM(e){
if(!e)e=window.event;
if(e.type=="mouseover")mouse=true;
else{ mouse=false; setTimeout("hideMenu()",100) }
}
function showMenu(x){
eval('document.all["subMenu'+sel+'"].style.visibility="hidden"');
sel = x;
eval('document.all["subMenu'+sel+'"].style.visibility="visible"');
}
function hideMenu(){
if(!mouse){ eval('document.all["subMenu'+sel+'"].style.visibility="hidden"');}
}
eval('document.all["phpddmMenu"].style.visibility="visible"');
<?
//######################## Internet Explorer
} elseif($browser == "ie") {?>
function handlerMM(e){
x = event.clientX;
y = event.clientY;
temp = 'subMenu' + sel;
x1 = document.all[temp].style.posLeft;
x2 = x1 + document.all[temp].offsetWidth;
y1 = document.all[temp].style.posTop;
y2 = y1 + document.all[temp].offsetHeight;
if ((x <= x1) || (x >= x2) || (y >= y2)) { eval('document.all["subMenu'+sel+'"].style.visibility="hidden"') }
}
function showMenu(x){
eval('document.all["subMenu'+sel+'"].style.visibility="hidden"');
sel = x;
eval('document.all["subMenu'+sel+'"].style.visibility="visible"');
}
document.onmousemove = handlerMM
eval('document.all["phpddmMenu"].style.visibility="visible"');
<?
//######################## Netscape Navigator
} elseif($browser == "ns") {?>
function handlerMM(e){
x = e.pageX
y = e.pageY
temp = 'subMenu' + sel;
x1 = document.layers[temp].left;
x2 = x1 + document.layers[temp].clip.width;
y1 = document.layers[temp].top;
y2 = y1 + document.layers[temp].clip.height;
if ((x <= x1) || (x >= x2) || (y >= y2)) { eval('document.layers["subMenu'+sel+'"].visibility="hidden"') }
}
function showMenu(x){
eval('document.layers["subMenu'+sel+'"].visibility="hidden"');
sel = x;
eval('document.layers["subMenu'+sel+'"].visibility="visible"');
}
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = handlerMM
eval('document.layers["phpddmMenu"].visibility="visible"');
<?
//######################## Netscape Navigator
} elseif($browser == "ns6") {?>
function handlerMM(e){
if (e.type=="mouseover") { mHide=false; } else { mHide=true; setTimeout("hideMenu()",1000) }
}
function hideMenu(){
if (mHide == true) {
menu = "subMenu" + sel;
document.getElementById(menu).style.visibility = "hidden";
}
}
function showMenu(x){
menu = "subMenu" + sel;
document.getElementById(menu).style.visibility = "hidden";
sel = x;
menu = "subMenu" + sel;
document.getElementById(menu).style.visibility = "visible";
}
<?
$str="";
for ($i=0; $i<=$Maxmenu; $i++) {
$str.= "document.getElementById(\"subMenu$i\").addEventListener(\"mouseout\", handlerMM, false);\n";
$str.= "document.getElementById(\"subMenu$i\").addEventListener(\"mouseover\", handlerMM, false);\n";
}
$str.= "document.getElementById(\"phpddmMenu\").style.visibility = \"visible\";\n";
echo $str;
} ?>
</script>