Need help! Pull down menu for products?

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
vsaletto
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Mon May 04, 2009 8:28 pm

Need help! Pull down menu for products?

Post by vsaletto » Wed May 06, 2009 9:30 am

Is there a way to get a pulldown menu in the header using AbleCommerce "ConLib" controls or Scriptlets? Please see the "artist's rendition" I drew here.

Image

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>
Any help would be greatly appreciated. Thank you.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Need help! Pull down menu for products?

Post by mazhar » Wed May 06, 2009 9:37 am

Have a look at following thread
viewtopic.php?f=47&t=8566

vsaletto
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Mon May 04, 2009 8:28 pm

Re: Need help! Pull down menu for products?

Post by vsaletto » Wed May 06, 2009 10:28 am

Thank you. It works perfectly!

vsaletto
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Mon May 04, 2009 8:28 pm

Mazhar, one more question.

Post by vsaletto » Fri May 29, 2009 12:20 pm

First, that pull down works perfectly. Thank you very much.

However, is there a way to also include products on that pulldown? As opposed to a list of categories and sub categories?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Need help! Pull down menu for products?

Post by mazhar » Sat May 30, 2009 1:55 am

Change its

Code: Select all

private void PopulateMenuItem(MenuItem parentMenu,int categoryId)
as below

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);
        }
    }
Now it will load products with categories as well.

vsaletto
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Mon May 04, 2009 8:28 pm

Re: Need help! Pull down menu for products?

Post by vsaletto » Mon Jun 01, 2009 4:50 pm

Thank you very much for your assistance with this. Unfortunately... it doesn't appear to be working. I wonder if it is the way that my menu is set up. Here is my code. I have 5 categories off of the root, and each has at least one product off of it.

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>

Post Reply