Adding optional (ie, can be disabled by Admin setting) item to main menu

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Basically, I'm adding a Silverlight 4 Bing Map as a new page to nopCommerce (e.g., to display customers on a map).  I'm stuck trying to figure out where to modify the database mappping to the model so that a new menu item can be added as optional (kinda like Forums and Blogs) and persisted (saved).

What I've done so far works great (map is displayed) so long as I comment out the optional section (ie, the IF block).  I'd like to be able to make this an Admin controllable item.  Here are the steps I've taken:
1. Add bool value to model
Modified [Project Root]\Libraries\Nop.Web\Models\Common\MenuModel.cs to add new boolean value:
        public bool MapEnabled { get; set; }
2. Register route
Modified [Project Root]\Libraries\Nop.Web\Infrastructure\RouteProvider.cs (right after home page stuff) and added:
            //Map
            routes.MapLocalizedRoute("Map",
                            "map",
                            new { controller = "Map", action = "Index" },
                            new[] { "Nop.Web.Controllers" });
3. Add conditional logic for menu item display
Modified [Project Root]\Libraries\Nop.Web\Views\Common\Menu.cshtml (right after home page stuff) and added:
    @if (Model.MapEnabled)
    {
        <li><a href="@Url.RouteUrl("Map")">@T("Map")</a></li>
    }
4. Add string resource to database
INSERT INTO [dbo].[LocaleStringResource]
VALUES(1,'Map','Map')
5. Create partial view base
A. Copied from existing [Project Root]\Libraries\Nop.Web\Views\Shared\_ColumnsOne.cshtml to create _ColumnsOneMap.cshtml
B. Modified _ColumnsOneMap.cshtml replace contents with (note map section):
@{
    Layout = "~/Views/Shared/_Root.cshtml";
}
<div class="master-wrapper-center-1">
    <div class="master-wrapper-cph-1">
       <div style="height:600px; overflow: scroll">
        @Helpers.Silverlight("~/ClientBin/BingMaps.Silverlight.xap", "4.0")
        </div>        
  
     @Html.Action("WidgetsByZone", "Widget", new { widgetZone = Nop.Core.Domain.Cms.WidgetZone.BeforeMainColumn })
        @RenderBody()
        @Html.Action("WidgetsByZone", "Widget", new { widgetZone = Nop.Core.Domain.Cms.WidgetZone.AfterMainColumn })
    </div>
</div>
6. Create new view that inherits from partial view
A. Add Map folder under [Project Root]\Libraries\Nop.Web\Views and add new view [Project Root]\Libraries\Nop.Web\Views\Map\Map\Index.cshtml to it
B. Modified Map.cshtml replace contents with:
@{
    Layout = "~/Views/Shared/_ColumnsOneMap.cshtml";

}
<div class="mapmain">
</div>

What am I missing?  I know the model has to be mapped (not mapped as in Bing Maps but code to database mapped) to the database but I can't figure out where this happens for the menu items.

Any help will be greatly appreciated.
12 years ago
Never mind... just figured it out (searched for all instances of forumenabled in the solution, it was obvious then)... had to:
- add new folder/file to Nop.Domain project... MapSettings.cs file.. MapSettings to inherit from ISettings
- modify CommonController.cs to: reference new map settings class, instantiate map settings variable, add reference to new bool value in menu
- add row to dbo.Settings for new map settings true/false value

It works great and am able to modify the value via the Admin console!

Next, need to add a tab to the General and Misc Settings screen to display map settings (and possibly add some additional ones).

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