/// <summary> /// Manage sitemap. You can use "SystemName" of menu items to manage existing sitemap or add a new menu item. /// </summary> /// <param name="rootNode">Root node of the sitemap.</param> public void ManageSiteMap(SiteMapNode rootNode) { rootNode.ChildNodes.Add(new SiteMapNode() { ActionName = "List", ControllerName = "AppVersion", Icon = "chemistry", SystemName = "Admin.AppVersion", Title = "AppVersion", Visible = true, RouteValues = new RouteValueDictionary { { "area", "Admin" } } }); }
private static void Iterate(SiteMapNode siteMapNode, XmlNode xmlNode) { PopulateNode(siteMapNode, xmlNode); foreach (XmlNode xmlChildNode in xmlNode.ChildNodes) { if (xmlChildNode.LocalName.Equals("siteMapNode", StringComparison.InvariantCultureIgnoreCase)) { var siteMapChildNode = new SiteMapNode(); siteMapNode.ChildNodes.Add(siteMapChildNode); Iterate(siteMapChildNode, xmlChildNode); } } }
private static void PopulateNode(SiteMapNode siteMapNode, XmlNode xmlNode) { //system name siteMapNode.SystemName = GetStringValueFromAttribute(xmlNode, "SystemName"); //title var nopResource = GetStringValueFromAttribute(xmlNode, "nopResource"); var localizationService = EngineContext.Current.Resolve<ILocalizationService>(); siteMapNode.Title = localizationService.GetResource(nopResource); //routes, url string controllerName = GetStringValueFromAttribute(xmlNode, "controller"); string actionName = GetStringValueFromAttribute(xmlNode, "action"); string url = GetStringValueFromAttribute(xmlNode, "url"); if (!string.IsNullOrEmpty(controllerName) && !string.IsNullOrEmpty(actionName)) { siteMapNode.ControllerName = controllerName; siteMapNode.ActionName = actionName; //apply admin area as described here - http://www.nopcommerce.com/boards/t/20478/broken-menus-in-admin-area-whilst-trying-to-make-a-plugin-admin-page.aspx siteMapNode.RouteValues = new RouteValueDictionary { {"area", "Admin"} }; } else if (!string.IsNullOrEmpty(url)) { siteMapNode.Url = url; } //image URL siteMapNode.Icon = GetStringValueFromAttribute(xmlNode, "icon"); //permission name var permissionNames = GetStringValueFromAttribute(xmlNode, "PermissionNames"); if (!string.IsNullOrEmpty(permissionNames)) { var permissionService = EngineContext.Current.Resolve<IPermissionService>(); siteMapNode.Visible = permissionNames.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Any(permissionName => permissionService.Authorize(permissionName.Trim())); } else { siteMapNode.Visible = true; } }
public XmlSiteMap() { RootNode = new SiteMapNode(); }