Fundamental changes were made to top menu customization in AxCMS.net 9. If you are using an earlier version of AxCMS.net and would like to know more about how to customize the old top menu, click here.
It is possible to customize the Management System’s TopMenu component by adding or changing menu items. This feature is useful if you want to extend the functionality of AxCMS.net or just rearrange the default menu structure.
Customizing the Silverlight Top Menu
To start customizing the top menu you will first need to define an extension class in the AxCMS.net web.config. You have to define a special key whose value consists of the class name and the name of the assembly where the extension class is situated:
<add key="TopMenuModelClass" value="Axinom.AECMS.TopMenuModel, AxCMS.BL" />
By definition, AxCMS.net will try to create the menu model based on the class that is defined in the configuration file. Extension class must extend the original menu class Axinom.AECMS.TopMenuModel, AxCMS.BL. The parent class has several methods that can be overridden for a customized model:
- GetTopMenuItems – all top menu items.
- GetHomeMenuItems – submenu of the “Home” menu.
- GetNewMenuItems – submenu of the “New” menu.
- GetEditMenuItems – submenu of the “Edit” menu.
- GetSettingsMenuItems – submenu of the “Admin” menu.
Here is a screenshot of the top menu with one custom top menu item “AxCMS”:

Submenus in the top menu item can be grouped into logical sections that have clear divisions:

Add More Submenu Items to a Top Menu Item
Let’s assume you want to extend the existing top menu item “Edit” with a new group which will list all sites, and each item will lead to the site details page. Here is a code snippet which shows how to do this, using menu model method overriding:
public override List<UxDropDownItemGroup> GetEditMenuItems()
{
List<UxDropDownItemGroup> groups = base.GetEditMenuItems(); // get parent items
var itemList = new List<UxDropDownItem>(); // create new list of items
int i = 1;
foreach (AxSite site in AxSiteDetector.Sites.Values)
{ // add all sites as separated item for the group
itemList.Add(new UxDropDownItem
{
Name = String.Format("Edit site #{0}", i),
URL = CMSConfigurationSettings.RootUrl + String.Format("/admin/categories/CategoryDetail.aspx?AxID={0}", site.NavigationRootNode)
});
i++;
}
groups.Add(new UxDropDownItemGroup { Items = itemList }); // add group to list
return groups; //return groups
}
Create a Custom Top Menu Item
If extending the existing top menu items is not enough, you can create more top menu items and add grouped submenus to them.
You can add up to five custom top menu items. They are inserted between the predefined items “Edit” and “Admin”.
The following snippet explains how to add custom a top menu item named “AxCMS”:
public override List<UxTopMenuItem> GetTopMenuItems()
{
var items = base.GetTopMenuItems(); // get parent items
items.Add(new UxTopMenuItem {
ID = TopMenuItemID.Custom, // please note that ID must be TopMenuItemID.Custom!
Name = "AxCMS",
ItemGroups = GetCustomMenuItems() // retrieve groups of items
}); // add one more item to the list
return items; // return top menu items
}
Limitations of the Top Menu Functionality in AxCMS.net 9.0
In version 9.0 it is not possible to add new items to the top menu. But it is still possible to extend the existing menus (“Home”, “New”, “Edit”, “Admin”). To get the full functionality, an upgrade to AxCMS.net 9.1 is required.