639 users online

How to add drop down mouse hover menu in nopCommerce

1 2 3 4 Next
Posted: 2 years ago Quote
By default we get normal top menu tabs with nopCommerce project

I would like to make it drop down mouse hover menus like we can see on www.nopCommerce.com

how to change current nopcommerce main menu tabs to mouse hover drop down menus ?

Any suggestions ?
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Please VOTE for the post if it helps you.

Thanks
Mike-nickname

If im not available here, post ur question on my site forum & I'll reply back there ASAP

www.strivingprogrammers.com
(Online Forums: ASP.NET, SQL, C#, AJAX, HTML, CSS, VB, C++, MS Office, Photoshop, Windows, Linux & more)
Posted: 2 years ago Quote
You can use an ASP.NET Menu server control.  I have made it so when I click save on the main categories page in the admin section that an XML file is created in the root directory.  When the store app loads, the category xml file loads into a DataTable and users can see one level down from the category roots.

You can see this in action at http://www.myshopandsearch.com by hovering over the arrow down image next to categories.

You can choose to go however many levels down you want to go.  Would you like me to post the code I used to make this happen?
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Got unique business needs?   Customize NopCommerce and make it do whatever you want!

Hope you enjoy NopCommerce as much as I do!

Contact me for an honest and quick quote: derek.yost@codesmartinc.com
http://www.linkedin.com/in/derekyost
Posted: 2 years ago Quote
yea ASP.NET menus are easy to integrate but yea still if you like it will be great if you can post your code here for category menus.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Please VOTE for the post if it helps you.

Thanks
Mike-nickname

If im not available here, post ur question on my site forum & I'll reply back there ASAP

www.strivingprogrammers.com
(Online Forums: ASP.NET, SQL, C#, AJAX, HTML, CSS, VB, C++, MS Office, Photoshop, Windows, Linux & more)
Posted: 2 years ago Quote
1) In Administration/Modules/Categories.ascx add OnClientClick="setEvent();" to the save button

2) In Administration/Categories.aspx add this inside the <asp:Content> tag:

    <input type="hidden" id="event" name="event" value="" />

    <script language="javascript" type="text/javascript">
        function setEvent() {
            $get("event").value = "saveXML";
        }
    </script>

3) In Administration/Categories.aspx add this at the top of the page:

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
    <%
        try
        {
            if ((Page.IsPostBack) && (Request.Form["event"].ToString() == "saveXML"))
            {
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["NopSqlConnection"].ConnectionString);
                try
                {
                    conn.Open();
                    DataTable dtCats = new DataTable("Categories");
                    string selectCategories = "SELECT CategoryID, Name, ParentCategoryID FROM Nop_Category WHERE (Published = 1) AND (Deleted = 0) ORDER BY Name";
                    SqlCommand cmd = new SqlCommand(selectCategories, conn);
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(dtCats);
                    dtCats.WriteXml(Server.MapPath("~/categories.xml"));
                }
                catch (Exception ex)
                {
                    LogManager.InsertLog(LogTypeEnum.Unknown, ex.Message, ex);
                }
                finally
                {
                    conn.Close();
                }
            }
        }
        catch (Exception ex)
        {
            LogManager.InsertLog(LogTypeEnum.Unknown, ex.Message, ex);
        }
    %>

4) At the bottom of Modules/CategoryNavigation.ascx add this:
<asp:PlaceHolder ID="phSubMenus" runat="server">
    <ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="imgDropMenu"
        PopDelay="500" PopupControlID="panelMenu" PopupPosition="Bottom">
    </ajaxToolkit:HoverMenuExtender>
    <asp:Panel ID="panelMenu" CssClass="panelMenu" runat="server">
        <asp:Menu ID="catsMenu"
            StaticHoverStyle-CssClass="catStaticHover"
            DynamicHoverStyle-CssClass="catDynHover"
            DynamicMenuItemStyle-CssClass="catDynMenuItem"
            DynamicMenuStyle-CssClass="catDynMenu"
            DynamicSelectedStyle-CssClass="catDynSelected"
            StaticMenuItemStyle-CssClass="catStaticMenuItem"
            StaticMenuStyle-CssClass="catStaticMenu"
            StaticSelectedStyle-CssClass="catStaticSelected"
            Orientation="Vertical"
            DisappearAfter="500"
            runat="server">
        </asp:Menu>
    </asp:Panel>
</asp:PlaceHolder>

Note: the panelMenu css class has to have visibility: hidden;

5) Add this at the top of Modules/CategoryNavigation.ascx

<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>

<script runat="server">
    protected override void OnPreRender(EventArgs e)
    {
        try
        {
            if (catsMenu.Items.Count == 0)
            {
                //create data table
                DataTable dtMenu = new DataTable("Categories");
                dtMenu.Columns.AddRange(
                    new DataColumn[] {
                                new DataColumn("CategoryID", typeof(int)),
                                new DataColumn("Name", typeof(string)),
                                new DataColumn("ParentCategoryID", typeof(int))
                            });
                dtMenu.PrimaryKey = new DataColumn[] { dtMenu.Columns["CategoryID"] };

                //load categories into data table
                dtMenu.ReadXml(Server.MapPath("~/categories.xml"));

                for (int i = 0; i < dtMenu.Rows.Count; i++)
                {
                    if (dtMenu.Rows[i].Field<int>("ParentCategoryID") == 0)
                    {
                        string url = string.Format(SettingManager.GetSettingValue("SEO.Category.UrlRewriteFormat"), "http://www.myshopandsearch.com/", dtMenu.Rows[i].Field<int>("CategoryID"), SEOHelper.GetSEName(dtMenu.Rows[i].Field<string>("Name")));
                        MenuItem mi = new MenuItem(dtMenu.Rows[i].Field<string>("Name"), "", "", url);
                        catsMenu.Items.Add(mi);

                        for (int j = 0; j < dtMenu.Rows.Count; j++)
                        {
                            if (dtMenu.Rows[j].Field<int>("ParentCategoryID") == dtMenu.Rows[i].Field<int>("CategoryID"))
                            {
                                string subURL = string.Format(SettingManager.GetSettingValue("SEO.Category.UrlRewriteFormat"), "http://www.myshopandsearch.com/", dtMenu.Rows[j].Field<int>("CategoryID"), SEOHelper.GetSEName(dtMenu.Rows[j].Field<string>("Name")));

                                MenuItem subMI = new MenuItem(dtMenu.Rows[j].Field<string>("Name"), "", "", subURL);
                                mi.ChildItems.Add(subMI);
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            LogManager.InsertLog(LogTypeEnum.Unknown, ex.Message, ex);
        }
        base.OnInit(e);
    }
</script>

You can experiment with this to get the levels to go as deep as you want.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Got unique business needs?   Customize NopCommerce and make it do whatever you want!

Hope you enjoy NopCommerce as much as I do!

Contact me for an honest and quick quote: derek.yost@codesmartinc.com
http://www.linkedin.com/in/derekyost
Posted: 2 years ago Quote
IE 8 doesn't like the asp.net Menu control. To work around that, an option is to insert this into the head of Root.master:

    <!-- Use IE7 mode -->
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Got unique business needs?   Customize NopCommerce and make it do whatever you want!

Hope you enjoy NopCommerce as much as I do!

Contact me for an honest and quick quote: derek.yost@codesmartinc.com
http://www.linkedin.com/in/derekyost
Posted: 2 years ago Quote
Thanks for providing me your code deccks

i did exactly how you guided me but i am getting this error message;

Server Error in '/' Application.
--------------------------------------------------------------------------------

The TargetControlID of 'HoverMenuExtender1' is not valid. A control with ID 'imgDropMenu' could not be found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The TargetControlID of 'HoverMenuExtender1' is not valid. A control with ID 'imgDropMenu' could not be found.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[InvalidOperationException: The TargetControlID of 'HoverMenuExtender1' is not valid. A control with ID 'imgDropMenu' could not be found.]
   System.Web.UI.ExtenderControl.RegisterWithScriptManager() +326771
   System.Web.UI.ExtenderControl.OnPreRender(EventArgs e) +19
   AjaxControlToolkit.ExtenderControlBase.OnPreRender(EventArgs e) +51
   AjaxControlToolkit.HoverMenuExtender.OnPreRender(EventArgs e) +37
   System.Web.UI.Control.PreRenderRecursiveInternal() +80
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Please VOTE for the post if it helps you.

Thanks
Mike-nickname

If im not available here, post ur question on my site forum & I'll reply back there ASAP

www.strivingprogrammers.com
(Online Forums: ASP.NET, SQL, C#, AJAX, HTML, CSS, VB, C++, MS Office, Photoshop, Windows, Linux & more)
Posted: 2 years ago Quote
deccks i visited your website, it looks good

could you please guide me what changes to make in .css style sheet of theme to make main menu tabs like yours

I want to stretch mine too like you have in 100% width of page (From "Search" To "Contact Us")
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Please VOTE for the post if it helps you.

Thanks
Mike-nickname

If im not available here, post ur question on my site forum & I'll reply back there ASAP

www.strivingprogrammers.com
(Online Forums: ASP.NET, SQL, C#, AJAX, HTML, CSS, VB, C++, MS Office, Photoshop, Windows, Linux & more)
Posted: 2 years ago Quote
I am sorry buddy, I forgot to mention the imgDropMenu...For me, it is the id of my drop down arrow image next to the CATEGORIES text...here is what my image tag looks like:

                    <a href="javascript:void(0)">
                        <img id="imgDropMenu" runat="server" align="right" src="../images/arrowDown.png"
                            border="0" alt="Category Menu" /></a>

You can use any image you want but make sure you give it an id="whatever" and runat="server" and then assign the TargetControlID of 'HoverMenuExtender1' like this:

TargetControlID="imgDropMenu"

or whatever image you want to use....you can use any control as the TargetControlID but the control you assign to TargetControlID must have id and runat attributes set.

The <a href="javascript:void(0)"> just makes it so that the mouse cursor turns to a hand when you hover over it and when you click, it does nothing.

As far as my layout of my website, do you just want to know how I got it to stretch?

find this in your styles sheet...this is what mine looks like now:

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

  MASTER PAGE WRAPPERS

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

.master-wrapper-page
{
  margin-top: 0px;
  width: 100%;
  min-width: 1000px;
}

let me know if this was not what you needed...I am glad to help.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Got unique business needs?   Customize NopCommerce and make it do whatever you want!

Hope you enjoy NopCommerce as much as I do!

Contact me for an honest and quick quote: derek.yost@codesmartinc.com
http://www.linkedin.com/in/derekyost
Posted: 2 years ago Quote
ok, Now i am not getting error message but the mouse hover menus are not working:

This is how it looks like right now: http://img96.imageshack.us/img96/5476/catxq.jpg



This is my code in categorynavigator.ascx

--------------------------------------------------------------------------------------------------
<%@ Control Language="C#" AutoEventWireup="true"
    Inherits="NopSolutions.NopCommerce.Web.Modules.CategoryNavigation" Codebehind="CategoryNavigation.ascx.cs" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>

<script runat="server">
    protected override void OnPreRender(EventArgs e)
    {
        try
        {
            if (catsMenu.Items.Count == 0)
            {
                //create data table
                DataTable dtMenu = new DataTable("Categories");
                dtMenu.Columns.AddRange(
                    new DataColumn[] {
                                new DataColumn("CategoryID", typeof(int)),
                                new DataColumn("Name", typeof(string)),
                                new DataColumn("ParentCategoryID", typeof(int))
                            });
                dtMenu.PrimaryKey = new DataColumn[] { dtMenu.Columns["CategoryID"] };

                //load categories into data table
                dtMenu.ReadXml(Server.MapPath("~/categories.xml"));

                for (int i = 0; i < dtMenu.Rows.Count; i++)
                {
                    if (dtMenu.Rows[i].Field<int>("ParentCategoryID") == 0)
                    {
                        string url = string.Format(SettingManager.GetSettingValue("SEO.Category.UrlRewriteFormat"), "http://www.myshopandsearch.com/", dtMenu.Rows[i].Field<int>("CategoryID"), SEOHelper.GetSEName(dtMenu.Rows[i].Field<string>("Name")));
                        MenuItem mi = new MenuItem(dtMenu.Rows[i].Field<string>("Name"), "", "", url);
                        catsMenu.Items.Add(mi);

                        for (int j = 0; j < dtMenu.Rows.Count; j++)
                        {
                            if (dtMenu.Rows[j].Field<int>("ParentCategoryID") == dtMenu.Rows[i].Field<int>("CategoryID"))
                            {
                                string subURL = string.Format(SettingManager.GetSettingValue("SEO.Category.UrlRewriteFormat"), "http://www.myshopandsearch.com/", dtMenu.Rows[j].Field<int>("CategoryID"), SEOHelper.GetSEName(dtMenu.Rows[j].Field<string>("Name")));

                                MenuItem subMI = new MenuItem(dtMenu.Rows[j].Field<string>("Name"), "", "", subURL);
                                mi.ChildItems.Add(subMI);
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            LogManager.InsertLog(LogTypeEnum.Unknown, ex.Message, ex);
        }
        base.OnInit(e);
    }
</script>
<div class="category-navigation">
    <div class="title">
        <%=GetLocaleResourceString("Category.Categories")%>
    </div>
    <div class="clear"></div>
    
    <div class="treeview">
    
        <ul>
            <asp:PlaceHolder runat="server" ID="phCategories" />
            
        </ul>
        
        
    </div>
    <a href="javascript:void(0)">
                        <img id="imgDropMenu" runat="server" align="right" src="http://www.quarktet.com/Icon-small.jpg"
                            border="0" alt="Category Menu" /></a>
</div>

<asp:PlaceHolder ID="phSubMenus" runat="server">
    <ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="imgDropMenu"
        PopDelay="500" PopupControlID="panelMenu" PopupPosition="Bottom">
    </ajaxToolkit:HoverMenuExtender>
    <asp:Panel ID="panelMenu" CssClass="panelMenu" runat="server">
        <asp:Menu ID="catsMenu"
            StaticHoverStyle-CssClass="catStaticHover"
            DynamicHoverStyle-CssClass="catDynHover"
            DynamicMenuItemStyle-CssClass="catDynMenuItem"
            DynamicMenuStyle-CssClass="catDynMenu"
            DynamicSelectedStyle-CssClass="catDynSelected"
            StaticMenuItemStyle-CssClass="catStaticMenuItem"
            StaticMenuStyle-CssClass="catStaticMenu"
            StaticSelectedStyle-CssClass="catStaticSelected"
            Orientation="Vertical"
            DisappearAfter="500"
            runat="server">
        </asp:Menu>
    </asp:Panel>
</asp:PlaceHolder>
----------------------------------------------------------------------------------------------------------
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Please VOTE for the post if it helps you.

Thanks
Mike-nickname

If im not available here, post ur question on my site forum & I'll reply back there ASAP

www.strivingprogrammers.com
(Online Forums: ASP.NET, SQL, C#, AJAX, HTML, CSS, VB, C++, MS Office, Photoshop, Windows, Linux & more)
Posted: 2 years ago Quote
I even noticed one thing, when i go to admin section > categories

i get this error:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls.

Source Error:


Line 5:     <%@ Import Namespace="System.Data" %>
Line 6:  <%@ Import Namespace="System.Data.SqlClient" %>
Line 7:      <%
Line 8:          try
Line 9:          {


Source File: /Administration/Categories.aspx    Line: 7
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Please VOTE for the post if it helps you.

Thanks
Mike-nickname

If im not available here, post ur question on my site forum & I'll reply back there ASAP

www.strivingprogrammers.com
(Online Forums: ASP.NET, SQL, C#, AJAX, HTML, CSS, VB, C++, MS Office, Photoshop, Windows, Linux & more)
1 2 3 4 Next