Created
August 28, 2011 10:01
-
-
Save caleb-vear/1176491 to your computer and use it in GitHub Desktop.
Custom SharePoint site menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected readonly List<SubSite> SubSites = new List<SubSite>(); | |
| protected void Page_PreRender(object sender, EventArgs e) | |
| { | |
| var siteMap = PortalSiteMapProvider.GlobalNavSiteMapProvider; | |
| var rootNode = siteMap.TryGetRootNode; | |
| SubSites.Add(new SubSite() | |
| { | |
| Title = rootNode.Title, | |
| Url = siteMap.CurrentSite.RootWeb.Url + "/m", | |
| IsCurrentSite = rootNode == siteMap.CurrentNode, | |
| }); | |
| foreach (SiteMapNode node in rootNode.ChildNodes) | |
| { | |
| SubSites.Add(new SubSite | |
| { | |
| Title = node.Title, | |
| Url = node.Url, | |
| IsCurrentSite = node == siteMap.CurrentNode, | |
| }); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="TopNav"> | |
| <ul> | |
| <%foreach (SubSite site in SubSites) {%> | |
| <li><a href="<%=site.Url %>" class="<%=(site.IsCurrentSite ? "topnavselected" : "topnav") %>"><%=site.Title %></a></li> | |
| <%}%> | |
| </ul> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment