
Currently, I have this code in my header:
Code: Select all
<div class="mastHead">
<DIV class="logo">
<a href="~/Default.aspx">[[ConLib:StoreLogo]]</a>
</DIV>
[[ConLib:SimpleCategoryList CategoryId="0"]]
</div>
Code: Select all
<div class="mastHead">
<DIV class="logo">
<a href="~/Default.aspx">[[ConLib:StoreLogo]]</a>
</DIV>
[[ConLib:SimpleCategoryList CategoryId="0"]]
</div>
Code: Select all
private void PopulateMenuItem(MenuItem parentMenu,int categoryId)
Code: Select all
private void PopulateMenuItem(MenuItem parentMenu,int categoryId)
{
CategoryCollection children = CategoryDataSource.LoadForParent(categoryId, true);
foreach (Category child in children)
{
MenuItem menuItem = new MenuItem();
menuItem.Text = child.Name;
menuItem.Value = child.CategoryId.ToString();
if (CategoryDataSource.CountForParent(child.CategoryId) > 1)
PopulateMenuItem(menuItem, child.CategoryId);
menuItem.NavigateUrl = child.NavigateUrl;
CatalogNodeCollection nodes = CatalogDataSource.LoadForCategory(child.CategoryId, true);
foreach (CatalogNode node in nodes)
if (node.CatalogNodeType == CatalogNodeType.Product)
menuItem.ChildItems.Add(new MenuItem(node.ChildObject.Name, string.Empty, string.Empty, node.NavigateUrl));
parentMenu.ChildItems.Add(menuItem);
}
}
Code: Select all
<%@ Control Language="C#" ClassName="CategoryMenuEx" %>
<script runat="server">
int _CategoryId;
protected void Page_Load(object sender, EventArgs e)
{
_CategoryId = PageHelper.GetCategoryId();
if (!Page.IsPostBack)
PopulateMenu();
}
private void PopulateMenu()
{
CategoryMenu.Items.Clear();
CategoryCollection children = CategoryDataSource.LoadForParent(0, true);
foreach (Category child in children)
{
MenuItem menuItem = new MenuItem();
menuItem.Text = child.Name;
menuItem.Value = child.CategoryId.ToString();
menuItem.NavigateUrl = child.NavigateUrl;
if (CategoryDataSource.CountForParent(child.CategoryId) > 0)
PopulateMenuItem(menuItem, child.CategoryId);
CategoryMenu.Items.Add(menuItem);
}
CategoryMenu.DataBind();
}
private void PopulateMenuItem(MenuItem parentMenu, int categoryId)
{
CategoryCollection children = CategoryDataSource.LoadForParent(categoryId, true);
foreach (Category child in children)
{
MenuItem menuItem = new MenuItem();
menuItem.Text = child.Name;
menuItem.Value = child.CategoryId.ToString();
if (CategoryDataSource.CountForParent(child.CategoryId) > 1)
PopulateMenuItem(menuItem, child.CategoryId);
menuItem.NavigateUrl = child.NavigateUrl;
CatalogNodeCollection nodes = CatalogDataSource.LoadForCategory(child.CategoryId, true);
foreach (CatalogNode node in nodes)
if (node.CatalogNodeType == CatalogNodeType.Product)
menuItem.ChildItems.Add(new MenuItem(node.ChildObject.Name, string.Empty, string.Empty, node.NavigateUrl));
parentMenu.ChildItems.Add(menuItem);
}
}
</script>
<div class="pageHeader">
<div class="caption">
<h1>
<asp:Localize ID="Caption" runat="server" Text="Categories"></asp:Localize>
</h1>
</div>
</div>
<div style="clear: both;">
<asp:Menu ID="CategoryMenu" runat="server" Orientation="Horizontal" BackColor="#000000" DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="11px" ForeColor="#FFFFFF" StaticSubMenuIndent="10px" CssClass="MenuFace">
<StaticSelectedStyle BackColor="#000000" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#fdb813" ForeColor="Black" />
<DynamicMenuStyle BackColor="#000000" />
<DynamicSelectedStyle BackColor="#1C5E55" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticHoverStyle BackColor="#fdb813" ForeColor="Black" />
</asp:Menu>
</div>