How to use the Navigation Menus module to create drop down primary navigation menus and footer links menus
At this point it is assumed that you have already –
- Installed the Navigation Menus module
- Created your Navigation Menu
- Defined the panels you wish to appear in your Navigation Menu
- Set your Navigation Menu to ‘Active’
Once this has been done it is necessary to add a link to the navigation menu in the style in which you want the navigation to appear.
On the navigation menu module configuration screen, select ‘Display Link’. This will display a line of code in a text area below your list of navigations. Copy this line of code.
Navigation menus - code snippet
This code needs to be placed in the header of your style; typically this will be in either the PageHeader.ascx
or DocumentMasthead.ascx
page control. For ease of styling the code should be placed inside two divs, ‘menu-outer’ and ‘menu-inner’. If you have been previously using a hard-coded navigation then these containing divs may already be in your style. Simply paste the copied line of code between these divs, and then replace the ‘<SomethingUnique>’ with a name for your navigation, making sure to also remove the angled brackets.
<div id="menu-outer">
<div id="menu-inner">
<%=StyleElement("CustomNavigation", "guid=dcc40622-1d82-473c-b129-95a93395ea3c;name=TopNav")%>
</div>
</div>
This name will be referred to in the CSS for your navigation, so it is useful to give it a name that is relevant. In the example we’re using the navigation is simply named ‘TopNav’.
Styling your Navigation
"menu-outer" and "menu-inner" are the containing divs for your navigation, generally they will contain any background images/colours that need to apply to the navigation as a whole, as well as any margin and padding to fit the navigation into your design
#menu-outer { clear: both; overflow: hidden; background: #f7f7f7 url("/EasySiteWeb/EasySite/StyleData/Web_Copy/Images/top-nav-top.gif") no-repeat left top; margin: 30px 0 5px 0; }
#menu-inner { overflow: hidden; padding-bottom: 4px; background: transparent url("/EasySiteWeb/EasySite/StyleData/Web_Copy/Images/top-nav-bottom.gif") no-repeat left bottom; }
The code above shows background images being applied to the entire menu. The whole of the navigation is displayed as a list, including child pages.
The style-element-outer div may have a default margin set, so it may be necessary to remove this to match your design.
#menu-inner .style-element-outer { margin: 0; }
As the navigation is generated as a list, remove the margin and padding that is set by default, as well as the list style and any custom background images that are usually used in your lists.
.custom-menu-TopNav ul, .custom-menu-TopNav li { list-style-type: none; margin: 0; padding: 0; background-image: none; }
"footer-menu-panel" is the container for each panel in your navigation. The border set here works as a dividing line between each panel. The 'first-child' pseudo-class can be used to remove the border from the first panel in the menu.
.custom-menu-TopNav .footer-menu-panel { border-left: 1px solid #dbdbdb; }.custom-menu-TopNav .footer-menu-panel:first-child { border-left: 0; }
Basic list structure of a Navigation Menu
The following CSS adds the fundamental styling for the way your navigation panels look. The first two lines apply to all panels.
.custom-menu-TopNav a.fm-panel-title:link, .custom-menu-TopNav a.fm-panel-title:visited { font-size: 1em; display: block; float: left; padding: 10px 24px; text-decoration: none; font-weight: normal; }.custom-menu-TopNav a.fm-panel-title:hover, .custom-menu-TopNav a.fm-panel-title:active { color: #fff; background-color: #662d91; }
The following lines of CSS add extra padding to specific panels. this is to ensure the panels fit completely within the menu container, ensuring the last item is flush to the edge of the menu.
.custom-menu-TopNav .fn-panel-beta a.fm-panel-title:link, .fn-panel-beta .custom-menu-TopNav a.fm-panel-title:visited, .custom-menu-TopNav .fn-panel-zeta a.fm-panel-title:link, .fn-panel-zeta .custom-menu-TopNav a.fm-panel-title:visited, .custom-menu-TopNav .fn-panel-eta a.fm-panel-title:link, .fn-panel-eta .custom-menu-TopNav a.fm-panel-title:visited { padding: 10px 26px; } .custom-menu-TopNav .fn-panel-lamda a.fm-panel-title:link, .fn-panel-lamda .custom-menu-TopNav a.fm-panel-title:visited { padding: 10px 25px 10px 26px; }
The following two lines apply CSS to specific panels in their hover and active states. In this example the navigation has rounded corners on the first and last panels, so a background image is required on hover.
.custom-menu-TopNav .fn-panel-alpha a.fm-panel-title:hover, .fn-panel-alpha .custom-menu-TopNav a.fm-panel-title:active { background: #662d91 url("/EasySiteWeb/EasySite/StyleData/Web_Copy/Images/top-nav-hover-tl.gif") no-repeat top left; } .custom-menu-TopNav .fn-panel-lamda a.fm-panel-title:hover, .fn-panel-lamda .custom-menu-TopNav a.fm-panel-title:active { background: #662d91 url("/EasySiteWeb/EasySite/StyleData/Web_Copy/Images/top-nav-hover-tr.gif") no-repeat top right; }
Our panels have now been styled to remove list styling, float to the left, and padding has been added. Hover states have also been added. The child pages will still be displayed at this point, this is expected.
Adding inital styling to navigation menus
This code needs to be placed in the header of your style; typically this will be in either the PageHeader.ascx
or DocumentMasthead.ascx
page control. For ease of styling the code should be placed inside two divs, ‘menu-outer’ and ‘menu-inner’. If you have been previously using a hard-coded navigation then these containing divs may already be in your style. Simply paste the copied line of code between these divs, and then replace the ‘<SomethingUnique>’ with a name for your navigation, making sure to also remove the angled brackets.
<div id="menu-outer">
<div id="menu-inner">
<%=StyleElement("CustomNavigation", "guid=dcc40622-1d82-473c-b129-95a93395ea3c;name=TopNav")%>
</div>
</div>
This name will be referred to in the CSS for your navigation, so it is useful to give it a name that is relevant. In the example we’re using the navigation is simply named ‘TopNav’.
Styling your Navigation
"menu-outer" and "menu-inner" are the containing divs for your navigation, generally they will contain any background images/colours that need to apply to the navigation as a whole, as well as any margin and padding to fit the navigation into your design
#menu-outer { clear: both; overflow: hidden; background: #f7f7f7 url("/EasySiteWeb/EasySite/StyleData/Web_Copy/Images/top-nav-top.gif") no-repeat left top; margin: 30px 0 5px 0; }
#menu-inner { overflow: hidden; padding-bottom: 4px; background: transparent url("/EasySiteWeb/EasySite/StyleData/Web_Copy/Images/top-nav-bottom.gif") no-repeat left bottom; }
The code above shows background images being applied to the entire menu. The whole of the navigation is displayed as a list, including child pages.
The style-element-outer div may have a default margin set, so it may be necessary to remove this to match your design.
#menu-inner .style-element-outer { margin: 0; }
As the navigation is generated as a list, remove the margin and padding that is set by default, as well as the list style and any custom background images that are usually used in your lists.
.custom-menu-TopNav ul, .custom-menu-TopNav li { list-style-type: none; margin: 0; padding: 0; background-image: none; }
"footer-menu-panel" is the container for each panel in your navigation. The border set here works as a dividing line between each panel. The 'first-child' pseudo-class can be used to remove the border from the first panel in the menu.
.custom-menu-TopNav .footer-menu-panel { border-left: 1px solid #dbdbdb; }
.custom-menu-TopNav .footer-menu-panel:first-child { border-left: 0; }
Adding selected state to navigation menus
We can now add functionality for drop down menus in.
The CSS in the following block is what makes the dropdowns in your navigation work.
.custom-menu-TopNav .footer-menu-panel { float: left; display: block; }
The list fm-panel-list contains the child pages that appear in your drop down menus. it is positioned absolutely so that the dropdowns appear in the correct place. The only part of the positioning you should need to change is 'top' as this will depend on how big your header is. The value set for 'left' is what hides the dropdown menu when it's not being hovered over. You may want to set a width on this list if some of the links within have long titles.
.custom-menu-TopNav ul.fm-panel-list { background: transparent url("/EasySiteWeb/EasySite/StyleData/Web_Copy/Images/top-nav-dd.gif") no-repeat 24px 0px; padding-top: 6px; text-align: left; position: absolute; top: 11.25em; left: -999em; z-index: 99; margin: 0px; display: block; height: auto; }
The span targeted here is for each item in your list of child pages
.custom-menu-TopNav ul.fm-panel-list span { padding-left: 10px; display: inline; background: transparent url("/EasySiteWeb/EasySite/StyleData/Web_Copy/Images/top-nav-bullet.gif") no-repeat left center; }
The CSS in the next line is what makes the drop down appear when hovering over a panel. The 'left' previously set to hide the dropdown off screen is set to 'auto', thus bringing it back into view in the right position.
.custom-menu-TopNav div.showList ul, .custom-menu-TopNav .footer-menu-panel ul.showList, .custom-menu-TopNav .footer-menu-panel:hover ul { left: auto; }
At this point, with the dropdowns hidden, the navigation menu is now displaying correctly.
Drop down navigation menus
Styling for child pages contained within the dropdown list is added. The CSS here is to add specific styling to the links in your dropdown menus.
.custom-menu-TopNav ul.fm-panel-list li.fm-panel-item { padding: 5px 0; }
.custom-menu-TopNav ul.fm-panel-list a.fm-panel-item:link { display: block; text-decoration: none; }
.custom-menu-TopNav ul.fm-panel-list a.fm-panel-item:hover { }
At this stage the menu is now fully functional and working as expected.
Getting Your Navigation to Work with IE6
Your navigation should now be functional in most browsers, but there is still some extra code needed to get it working in Internet Explorer 6. This is because IE6 does not support onhover events for anything other than an anchor tag.
Getting the navigation to work with IE6 is simple, requiring an extra JavaScript file that can be copied straight from the Easysite Default style.
In the Default style, navigate to the scripts folderStyleData\Default\Scripts
Located in this folder is a file named ‘dropdown.js’ - simply copy and paste this file into the Scripts folder of your own style.
Once this has been done you just need to add one line of code to your DocumentHeader.ascx page control, to allow the script to be brought in. Replacing ‘Your_Style’ with the actual name of the style where the script is located, the code is as follows –
<script type="text/javascript" src="/EasySiteWeb/EasySite/StyleData/Your_Style/Scripts/dropdown.js"></script>