Tuesday, June 26, 2007

Aspdotnetstorefront Menu

Some things are easier than you think they're going to be, and that just makes my whole day! So every single client we've had has requested the top categories go horizontally across the top in the menu instead of vertical submenus under Category, and to accomodate this, we've hard-coded the menus in menuData.xml in the skins directory.

What we lose here is the dynamic control of the menus for our clients, meaning they have to touch an xml file in addition to setting up the categories, and i don't know many product managers who speak xml.

So what I found was a curious line of code in the templatebase.cs file in app_code. Look at the Page_Load function and the section commented "// Find Categories menu top" and the line which starts with a call to AddEntityMenuXsl. See the final parameter being passed into that method is string.Empty. Well, when i look at AddEntityMenuXsl, I see that we have a piece of code that allows us to add a ROOT level element if the parameter length is greater than 0. So I just made my method call look like this:

AddEntityMenuXsl(doc, "Category", AppLogic.CategoryEntityHelper.m_TblMgr, mNode, 0, "1");

and VOILA! I now have a dynamic menu with the categories across the top! With just a little itty bitty code change. Some days programming is berry berry good to me :)

6 comments:

Tatvaa - Complete IT firm said...

Awesome sir! .. that was a beautiful solution .. but there's a small issue I'm facing here .. when I change templatebase.cs the way you explained and try to login to the control panel, it gives the following error: System.ArgumentException: The node to be removed is not a child of this node.
// now get rid of the parent placeholder node!
Line 388: doc.SelectSingleNode("/SiteMap").RemoveChild(mnuItem);
Please help me .. I require it quite urgently .. if possible, please revert on my mail id: akashwh2003@gmail.com
Many Thanks - Akash

IZI said...
This comment has been removed by the author.
IZI said...

Or, in the menuData.xml add a zero to the Categories menu item
item Text="(!menu.Categories0!)" LookId="TopItemLook"

Fun Box said...

I am trying to take one category out of resources "Who we Support" how do I do this? I see what you are referring to by completely giving each one a tab, but I only want one of them to move out and onto it's own. Please help and thank you!

Shoebox Savings said...

I know this is an old article but I was hoping you'd be kind enough to help me out. I have a aspdotnetstorefront and I would like to add a wordpress blog. Wordpress specifically (if possible) because of all the extra plugins they have. I would like to have my blog set up as www.mydomain.com/MyArticles
or something similar. Is is possible for a non developer to install that and get it running and use my template.aspx/skins?

Thanks.

Unknown said...

ASPDOTNETSTOREFRONT Development
Can u help me to describe the ASPDOTNETSTOREFRONT. I want collect the information that which is more benificial in between Nopcommerce and ASPNOTSTOREFRONT.