Adding Menu Items to Customer Navigation

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hi,

Can anyone advise me on how to add a menu item to the customer navigation from a plugin?
So currently under "My Account" a customer would see:
- Customer info
- Addresses
- Orders
- Downloadable products
- Back in stock subscriptions
- Change password
- My product reviews

Whereas I'd like to add a further menu item between Orders and Downloadable products.

Thanks,
Max
7 years ago
Hi Max,

You can override the view and add any custom options / menu items.

Please see this nopCommerce Plugin Guide:

Part 1 -
http://www.strivingprogrammers.com/Beginners-guide-to-nopCommerce-plugin-development-ASP-NET-MVC-based-e-Commerce-solution

Part 2 -
http://www.strivingprogrammers.com/Beginners-Guide-to-nopCommerce-Plugin-Development-ASP-NET-MVC-Based-e-Commerce-Solution-Part-2
7 years ago
Hi L.K

Thanks for your answer.
I'm actually referring to the customer navigation items and not navigation items of the website itself (I'm speaking of the navigation items when the customer is logged in and navigated to his account, i.e.: www.domain.com/customer/info). The customer navigation items are been created and added to the CustomerNavigationModel in the CustomerController.cs controller, which looks like this:


        private CustomerNavigationModel GetCustomerNavigation(int selectedTabId = 0)
        {
            var model = new CustomerNavigationModel();

            model.CustomerNavigationItems.Add(new CustomerNavigationItemModel
            {
                RouteName = "CustomerInfo",
                Title = _localizationService.GetResource("Account.CustomerInfo"),
                Tab = CustomerNavigationEnum.Info,
                ItemClass = "customer-info"
            });
......


I don't want to touch the core and add my own navigation item to the CustomerController controller. Copying the CustomerNavigation.cshtml page and changing it won't work, then as mentioned above the items are added on the controller and is not static content of the page.

Any ideas?
7 years ago
u can use all in one plugin

http://www.hezyziv.com/all-in-one

just enter widget zone: account_navigation_after
and your html code

<li><a href="">link</a></li>
7 years ago
Yes, I know, I'm fully aware of widget zone (
@Html.Widget("account_navigation_after")
and others) but that is not what I want to achieve. What I want is to add a additional menu item Quotation inside the customer navigation section between the Orders and Downloadable Products tabs. How can I achieve this programmatically within my plugin?
7 years ago
MaxM wrote:
Copying the CustomerNavigation.cshtml page and changing it won't work, then as mentioned above the items are added on the controller and is not static content of the page.

But the CustomerNavigationModel is passed to the view. If you override the view you can perform any manipulations you like on the model, including inserting new items.

Other approaches:
1. Override the CustomerNavigation ActionResult from your plugin.
2. Use an Action Filter to alter the CustomerNavigationModel after it's been generated.
3. Override the PostInitialize method (inherited from BaseNopModel) to alter the CustomerNavigationModel after it's been generated
7 years ago
Thanks a bunch, Pete, very helpful! I must have misunderstood what L.K meant by copying and overwriting the view - but now understand thanks to your explanation.
7 years ago
MaxM wrote:
Thanks a bunch, Pete, very helpful! I must have misunderstood what L.K meant by copying and overwriting the view - but now understand thanks to your explanation.


Hi Max,

Yes, you will have to override the default view from your custom plugin (CustomerNavigation ActionResult) in your case as Pete mentioned above in order to add custom menu items.

In the plugin development guide you can see how to override a view by a plugin in nopCommerce.

Please let us know if you have any question(s).
7 years ago
Hi L.K.,

Thanks also to you! Your and Pete's support is highly appreciated. I just love the Nop community, it has some great minds always trying to help.

Thanks for everything!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.