Lately a customer of mine had specific demands regarding their portal site. They wanted menu items containing sub menu items to be unclickable. Now this is not standard SharePoint menu behavior, so I Bang some about this. (Is Bang past tense for Bing?).
Anyways, there is a lot to find about overriding the menu control. Especially Microsoft (http://blogs.msdn.com/sharepoint/archive/2006/12/02/customizing-the-wss-3-0-moss-2007-menu-control.aspx) has some clear explanation on how to do this.
In short: you cannot override the MOSS menu control class because it is sealed. Therefore Microsoft has provided us with source code that can be used for this goal. This class you can override or tweak.
As I mentioned some menu items had to be "unclickable". This I achieved by doing the following:
First I added a method:
private void DisableParentMenuItems(MenuItem menuItem)
{
// No kids. Keep this one selectable
if (menuItem.ChildItems.Count == 0)
return;
// Kids. Process them
foreach (MenuItem childItem in menuItem.ChildItems)
DisableParentMenuItems(childItem);
// Kids. This menu item may not be clickable.
// Menu item with depth=0 is the root item and is the only one exception that should be selectable in case we use portal root site in navigation
// which we dont here.
if (menuItem.Depth >= 0)
menuItem.Selectable = false;
//menuItem.ToolTip += menuItem.Depth.ToString();
}
After that I added code to the end of the OnPreRender method:
// iterate through all top level menu items
foreach (MenuItem menuItem in this.Items)
DisableParentMenuItems(menuItem);
Make sure you use the standard procedure to have the menu control deployed (I used a solution for this), having the SafeControl added etc. The last thing to do is to modify the master page in order to use the new menu control (and don't forget the publishing of the page).