行动果然利索!我最近把MAMBO菜单自动分级源代码分享一下!不过MAMBO有点歧视中国人。认为我们只会索取,其实,我自己也做了几个组件!只是不太设计不太科学。
土豆大哥的MAMBO用什么BBS组件?TSF 的还是loudmouth的?我感觉TSF速度比较快点。
mod_mainmenu.class.php将44行if 条件语句换 case 形式即可,然后自已定义每级的CSS
-------------------------------------------------------------------------------------------------------------------
function mosGetMenuLink( $mitem, $level=0, $class_sfx='' ) {
global $Itemid, $mosConfig_live_site;
$txt = '';
switch ($mitem->type) {
case 'separator';
// do nothing
break;
case 'url':
if (eregi( "index.php\?", $mitem->link )) {
//$mitem->link .= "&Returnid=$Itemid";
if (!eregi( "Itemid=", $mitem->link )) {
$mitem->link .= "&Itemid=$mitem->id";
}
}
break;
default:
$mitem->link .= "&Itemid=$mitem->id";
break;
}
$mitem->link = str_replace( '&', '&', $mitem->link );
if (strcasecmp(substr($mitem->link,0,4),"http"
) {
$mitem->link = sefRelToAbs($mitem->link);
}
$menuclass = "mainlevel$class_sfx";
原来的
if ($level > 0) {
$menuclass = "sublevel$class_sfx";
}
新的,可以为每一级自定义样式的
switch($level)
{
case "1":
$menuclass = "sublevel$class_sfx";
break;
case "2":
$menuclass = "sublevel2$class_sfx";
break;
case "3":
$menuclass = "sublevel3$class_sfx";
break;
case "4":
$menuclass = "sublevel4$class_sfx";
break;
case "5":
$menuclass = "sublevel5$class_sfx";
break;
}
switch ($mitem->browserNav) {
// cases are slightly different
case 1:
// open in a new window
$txt = "<a href=\"$mitem->link\" target=\"_window\" class=\"$menuclass\">$mitem->name</a>\n";
break;
case 2:
// open in a popup window
$txt = "<a href=\"#\" onClick=\"javascript: window.open('$mitem->link', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\" class=\"$menuclass\">$mitem->name</a>\n";
break;
case 3:
// don't link it
$txt = "<span class=\"$menuclass\">$mitem->name</span>\n";
break;
default: // formerly case 2
// open in parent window
$txt = "<a href=\"$mitem->link\" class=\"$menuclass\">$mitem->name</a>\n";
break;
}
return $txt;
}
----------------------------------------------------------------------------------------------------------------
调整你选用Templete中的CSS
以下是我分了6级的菜单CSS MAINLEVEL是第一级的。其实我看3级足够了太多容易影响速度
/* --Default Class Settings-- */
/* --Mainlevel-- */
.mainlevel {
PADDING-BOTTOM: 4px; WIDTH: 100%; PADDING-TOP: 4px; LETTER-SPACING: 2px
}
a.mainlevel:link{
PADDING-LEFT: 15px; FONT-WEIGHT: 700; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; COLOR: #666666; PADDING-TOP: 4px; BORDER-BOTTOM: #EBEBEB 1px solid; BORDER-LEFT: #FFFFFF 3px solid;BACKGROUND-COLOR: #ffffff
}
a.mainlevel:active {
PADDING-LEFT: 15px; FONT-WEIGHT: 700; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; COLOR: #666666; PADDING-TOP: 4px; BORDER-BOTTOM: #EBEBEB 1px solid; BORDER-LEFT: #FFFFFF 3px solid;BACKGROUND-COLOR: #ffffff
}
a.mainlevel:visited {
PADDING-LEFT: 15px; FONT-WEIGHT: 700; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; COLOR: #666666; PADDING-TOP: 4px; BORDER-BOTTOM: #EBEBEB 1px solid; BORDER-LEFT: #FFFFFF 3px solid;BACKGROUND-COLOR: #ffffff
}
A.mainlevel:hover {
PADDING-LEFT: 15px; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; COLOR: #285078; PADDING-TOP: 4px; BORDER-BOTTOM: #EBEBEB 1px solid; BORDER-LEFT: #ff9900 3px solid; BACKGROUND-COLOR: #ffffff
}
/* ------------------------------------------Sublevel--------------------------------------- */
.sublevel {
PADDING-BOTTOM: 4px; WIDTH: 100% ; PADDING-TOP: 4px;
}
a.sublevel:link{
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: 500; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; COLOR: #000000; PADDING-TOP: 4px; BORDER-LEFT: #ff9900 3px solid;BACKGROUND-COLOR: #ebf8ff
}
a.sublevel:active {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: 500; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; COLOR: #000000; PADDING-TOP: 4px; BORDER-LEFT: #ff9900 3px solid;BACKGROUND-COLOR: #ebf8ff
}
a.sublevel:visited {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: 500; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; COLOR: #000000; PADDING-TOP: 4px; BORDER-LEFT: #ff9900 3px solid;BACKGROUND-COLOR: #ebf8ff
}
A.sublevel:hover {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; COLOR: #285078; PADDING-TOP: 4px; BORDER-LEFT: #669933 3px solid; BACKGROUND-COLOR: #ffffff
}
/* -----------------------------------------Sublevel2--------------------------------------- f5f5f5 */
.sublevel2 {
PADDING-BOTTOM: 1px; WIDTH: 100%; PADDING-TOP: 1px
}
A.sublevel2:link {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; BORDER-LEFT: #3366ff 6px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #3366ff 1px dashed; BACKGROUND-COLOR: #ffffff
}
A.sublevel2:active {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; BORDER-LEFT: #3366ff 6px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #3366ff 1px dashed; BACKGROUND-COLOR: #ffffff
}
A.sublevel2:visited {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; BORDER-LEFT: #3366ff 6px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #3366ff 1px dashed; BACKGROUND-COLOR: #ffffff
}
A.sublevel2:hover {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; BORDER-LEFT: #ff3300 6px solid; COLOR: #285078; PADDING-TOP: 1px; BORDER-BOTTOM: #999999 1px dashed; BACKGROUND-COLOR: #ffffff
}
/* -----------------------------------------Sublevel3--------------------------------------- */
.sublevel3 {
PADDING-BOTTOM: 1px; WIDTH: 100%; PADDING-TOP: 1px;
}
a.sublevel3:link{
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #f5f5f5 1px solid; BORDER-LEFT: #CCCCCC 3px solid;border-bottom-style: dashed;BACKGROUND-COLOR: #DAF2FF
}
a.sublevel3:active {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #f5f5f5 1px solid; BORDER-LEFT: #CCCCCC 3px solid;border-bottom-style: dashed;BACKGROUND-COLOR: #DAF2FF
}
a.sublevel3:visited {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #f5f5f5 1px solid; BORDER-LEFT: #CCCCCC 3px solid;border-bottom-style: dashed;BACKGROUND-COLOR: #DAF2FF
}
A.sublevel3:hover {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #285078; PADDING-TOP: 1px; BORDER-BOTTOM: #999999 1px solid; BORDER-LEFT: #a26b6b 3px solid; border-bottom-style: dashed; BACKGROUND-COLOR: #ffffff
}
/* -----------------------------------------Sublevel4--------------------------------------- */
.sublevel3 {
PADDING-BOTTOM: 1px; WIDTH: 70%; PADDING-TOP: 1px;
}
a.sublevel3:link{
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #f5f5f5 1px solid; BORDER-LEFT: #CCCCCC 3px solid;border-bottom-style: dashed;BACKGROUND-COLOR: #CBEDFF
}
a.sublevel3:active {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #f5f5f5 1px solid; BORDER-LEFT: #CCCCCC 3px solid;border-bottom-style: dashed;BACKGROUND-COLOR: #CBEDFF
}
a.sublevel3:visited {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #f5f5f5 1px solid; BORDER-LEFT: #CCCCCC 3px solid;border-bottom-style: dashed;BACKGROUND-COLOR: #CBEDFF
}
A.sublevel3:hover {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #285078; PADDING-TOP: 1px; BORDER-BOTTOM: #999999 1px solid; BORDER-LEFT: #a26b6b 3px solid; border-bottom-style: dashed; BACKGROUND-COLOR: #ffffff
}
/* -----------------------------------------Sublevel5--------------------------------------- */
.sublevel3 {
PADDING-BOTTOM: 1px; WIDTH: 65%; PADDING-TOP: 1px;
}
a.sublevel3:link{
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #f5f5f5 1px solid; BORDER-LEFT: #CCCCCC 3px solid;border-bottom-style: dashed;BACKGROUND-COLOR: #BEE9FF
}
a.sublevel3:active {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #f5f5f5 1px solid; BORDER-LEFT: #CCCCCC 3px solid;border-bottom-style: dashed;BACKGROUND-COLOR: #BEE9FF
}
a.sublevel3:visited {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: #f5f5f5 1px solid; BORDER-LEFT: #CCCCCC 3px solid;border-bottom-style: dashed;BACKGROUND-COLOR: #BEE9FF
}
A.sublevel3:hover {
PADDING-RIGHT: 10px; PADDING-LEFT: 5px; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; COLOR: #285078; PADDING-TOP: 1px; BORDER-BOTTOM: #999999 1px solid; BORDER-LEFT: #a26b6b 3px solid; border-bottom-style: dashed; BACKGROUND-COLOR: #ffffff
}
/* -----------------------------------------Sublevel6--------------------------------------- */