Not sure how many of you will be familiar with Stu Nicholls site CSS Play (http://www.cssplay.co.uk/) but he has some really good menus built that are standards compliant. One in particular is a flyout menu that uses no javascript only a portion of CSS.
The problem wtih this menu system is it relies on IE Conditional statements so getting it to work in kentico was a bit of a pain. Here is how I did it...
******You will have to modify the source code of kentico *********
In the CMS Controls subproject you will need to modify the CMSListMenu.cs file.
1) Find the getItems method
2) Scroll all the way to the bottom of the method until you see where it appends </a> to the result string.
You want to append the IE 7 conditional statement to the </a>
The code should look like this -
if ((isHighlightedItem & !(DisplayHighlightedItemAsLink)) || (inactiveitem))
{
result.Append("</span>");
}
else
{
if (this.mProperties.DataSource.Tables[0].Select("NodeParentID = " + System.Convert.ToInt32(dr["NodeID"])).Length != 0)
{
result.Append("<!--[if IE 7]><!--></a><!--<![endif]-->");
}
else
{
result.Append("</a>");
}
}
Now you need to catch the recursion and append the other conditional statements IF AND ONLY IF there is a sub menu.
// if there is any child, create a UL (submenu)
if (this.mProperties.DataSource.Tables[0].Select("NodeParentID = " + System.Convert.ToInt32(dr["NodeID"])).Length != 0)
{
result.Append("<!--[if lte IE 6]><table><tr><td><![endif]-->");
result.Append(GetItems(System.Convert.ToInt32(dr["NodeID"]), indentLevel + 1));
if ((isHighlightedItem & !(DisplayHighlightedItemAsLink)) || (inactiveitem))
{
result.Append("<!--[if lte IE 6]></td></tr></table><![endif]-->");
}
else
{
result.Append("<!--[if lte IE 6]></td></tr></table></a><![endif]-->");
}
// Indent the </LI> by indentLevel + 1
for (i = 0; i <= indentLevel + 1; i++)
{
result.Append("\t");
}
}
Now for the CSS (You may have to modify this to look correctly such as changing the margins a bit and colors)
.menu {
margin:-66px 0px 0px 0px;
position:absolute;
z-index:2000;
}
.menu img {
margin:0px 0px -2px 0px;
}
.menu ul {
width:161px;
list-style-type:none;
list-style:none;
background:#131313;
}
/* hack for IE5.5 */
* html .menu ul { margin-left:-16px; margin-left:0; }
.menu table {position:absolute; border-collapse:collapse; top:0; left:0; z-index:100; font-size:1em;}
.menu ul li {
width:161px;
position:relative;
}
.menu ul li a {
color:#fff;
font-size:12px;
font-style: normal;
font-weight: bold !important;
text-decoration:none;
padding-left: 9px;
padding-right: 9px;
padding-top: 5px !important;
padding-bottom: 5px !important;
display:block;
}
.menu ul li a:hover {
color:#fff;
background:#32312d;
font-size:12px;
font-style: normal;
font-weight: bold !important;
text-decoration:none;
padding-left: 9px;
padding-right: 9px;
padding-top: 5px !important;
padding-bottom: 5px !important;
display:block;
}
/* hack for IE5.5 */
* html .menu a, * html .menu a:visited {
color:#fff;
font-size:12px;
font-style: normal;
font-weight: bold !important;
text-decoration:none;
padding-left: 9px;
padding-right: 9px;
padding-top: 5px !important;
padding-bottom: 5px !important;
display:block;
}
/* style the link hover */
* html .menu a:hover {
color:#fff;
background:#32312d;
font-size:12px;
font-style: normal;
font-weight: bold !important;
text-decoration:none;
padding-left: 9px;
padding-right: 9px;
padding-top: 5px !important;
padding-bottom: 5px !important;
display:block;
}
/* ****** THIS IS FOR LINKS THAT ARE INACTIVE ****** */
.menu ul li span {
color:#fff;
font-size:12px;
font-style: normal;
font-weight: bold !important;
text-decoration:none;
padding-left: 9px;
padding-right: 9px;
padding-top: 5px !important;
padding-bottom: 5px !important;
display:block;
}
.menu ul li span:hover {
color:#fff;
background:#32312d;
font-size:12px;
font-style: normal;
font-weight: bold !important;
text-decoration:none;
padding-left: 9px;
padding-right: 9px;
padding-top: 5px !important;
padding-bottom: 5px !important;
display:block;
}
/* hack for IE5.5 */
* html .menu span, * html .menu span:visited {
color:#fff;
font-size:12px;
font-style: normal;
font-weight: bold !important;
text-decoration:none;
padding-left: 9px;
padding-right: 9px;
padding-top: 5px !important;
padding-bottom: 5px !important;
display:block;
}
/* style the link hover */
* html .menu span:hover {
color:#fff;
background:#32312d;
font-size:12px;
font-style: normal;
font-weight: bold !important;
text-decoration:none;
padding-left: 9px;
padding-right: 9px;
padding-top: 5px !important;
padding-bottom: 5px !important;
display:block;
}
/* hide the sub levels and give them a positon absolute so that they take up no room */
.menu ul ul {
visibility:hidden;
position:absolute;
top:0;
left:161px;
}
/* make the second level visible when hover on first level list OR link */
.menu ul li:hover ul, .menu ul a:hover ul {
visibility:visible;
}
/* keep the third level hidden when you hover on first level list OR link */
.menu ul :hover ul ul {
visibility:hidden;
}
/* keep the fourth level hidden when you hover on second level list OR link */
.menu ul :hover ul :hover ul ul{
visibility:hidden;
}
/* make the third level visible when you hover over second level list OR link */
.menu ul :hover ul :hover ul{
visibility:visible;
}
/* make the fourth level visible when you hover over third level list OR link */
.menu ul :hover ul :hover ul :hover ul {
visibility:visible;
}
Add the CSSListMenu webpart to your page and wrap it in a div with a class menu and you should be good to go...