private string GetSubItemsHtml(string menuTemplate, string menuItemTemplate, CmsMenuItem parentItem) { string subItemsHtml = ""; string subMenuHtml = menuTemplate; foreach (CmsMenuItem subItem in parentItem.GetSubMenuItems()) { string subItemHtml = menuItemTemplate; subItemHtml = subItemHtml.Replace("{MenuItem.Name}", subItem.Name); subItemHtml = subItemHtml.Replace("{MenuItem.Title}", subItem.Title); subItemHtml = subItemHtml.Replace("{MenuItem.Url}", subItem.Url); subItemHtml = subItemHtml.Replace("{MenuItem.Target}", subItem.Target); subItemHtml = subItemHtml.Replace("{MenuItem.CssClass}", subItem.CssClass); subItemHtml = subItemHtml.Replace("{MenuItem.Link}", createHyperLink(subItem)); subItemHtml = subItemHtml.Replace("{/MenuItem.Link}", "</a>"); subItemHtml = subItemHtml.Replace("{MenuItem.ImageUrl}", parentItem.ImageUrl); subItemHtml = subItemHtml.Replace("{MenuItem.ImageHoverUrl}", parentItem.ImageHoverUrl); subItemHtml = subItemHtml.Replace("{MenuItem.ImageActiveUrl}", parentItem.ImageActiveUrl); string subSubItemsHtml = GetSubItemsHtml(menuTemplate, menuItemTemplate, subItem); subItemHtml = subItemHtml.Replace("{MenuItem.ChildItems}", subSubItemsHtml); //if (subSubItemsHtml != "") //{ // subMenuHtml = subMenuHtml.Replace("<!--{MenuItems}-->" + menuItemTemplate + "<!--{/MenuItems}-->", subSubItemsHtml); // subMenuHtml = subMenuHtml.Replace("{MenuItems}" + menuItemTemplate + "{/MenuItems}", subSubItemsHtml); // subItemHtml += subMenuHtml; //} subItemsHtml += subItemHtml; } if (subItemsHtml != "") { subMenuHtml = subMenuHtml.Replace("<!--{MenuItems}-->" + menuItemTemplate + "<!--{/MenuItems}-->", subItemsHtml); subMenuHtml = subMenuHtml.Replace("{MenuItems}" + menuItemTemplate + "{/MenuItems}", subItemsHtml); } else { subMenuHtml = ""; } return(subMenuHtml); }
private string GetSubItemsHtml(string subMenuTemplate, string subItemTemplate, CmsMenuItem mainItem) { string subItemsHtml = ""; string subMenuHtml = subMenuTemplate; foreach (CmsMenuItem subItem in mainItem.GetSubMenuItems()) { string subItemHtml = subItemTemplate; subItemHtml = subItemHtml.Replace("{SubItem.Name}", subItem.Name); subItemHtml = subItemHtml.Replace("{SubItem.Title}", subItem.Title); subItemHtml = subItemHtml.Replace("{SubItem.Url}", subItem.Url); subItemHtml = subItemHtml.Replace("{SubItem.Target}", subItem.Target); subItemHtml = subItemHtml.Replace("{SubItem.Link}", createHyperLink(subItem)); subItemHtml = subItemHtml.Replace("{/SubItem.Link}", "</a>"); subItemHtml = subItemHtml.Replace("{SubItem.ImageUrl}", mainItem.ImageUrl); subItemHtml = subItemHtml.Replace("{SubItem.ImageHoverUrl}", mainItem.ImageHoverUrl); subItemHtml = subItemHtml.Replace("{SubItem.ImageActiveUrl}", mainItem.ImageActiveUrl); string subSubItemsHtml = GetSubItemsHtml(subMenuTemplate, subItemTemplate, subItem); if (subSubItemsHtml != "") { subMenuHtml = subMenuHtml.Replace("<!--{SubMenuItems}-->" + subItemTemplate + "<!--{/SubMenuItems}-->", subSubItemsHtml); subMenuHtml = subMenuHtml.Replace("{SubMenuItems}" + subItemTemplate + "{/SubMenuItems}", subSubItemsHtml); subItemHtml += subMenuHtml; } subItemsHtml += subItemHtml; } if (subItemsHtml != "") { subMenuHtml = subMenuHtml.Replace("<!--{SubMenuItems}-->" + subItemTemplate + "<!--{/SubMenuItems}-->", subItemsHtml); subMenuHtml = subMenuHtml.Replace("{SubMenuItems}" + subItemTemplate + "{/SubMenuItems}", subItemsHtml); } else { subMenuHtml = ""; } return(subMenuHtml); }