CarpeDiem wrote:Hello guys. Im new here, and I want to move business on nopcommerce. How I can do this from picture below?
Hi,
You can do it as following steps:
- Go to Admin > Configuration > Settings > All Settings (Advanced).
- Add a new setting with:
+ Key is "ShowDefaultMenuItems",
+ Value is "True"
- Copy the "TopMenu.cshtml" view to the "Themes/DefaultClean/Views/Catalog" folder.
- Modify this view:
BEFORE
@model TopMenuModel
@using Nop.Core.Domain
@using Nop.Core.Infrastructure
@using Nop.Web.Models.Catalog;
@{
var isRtl = this.ShouldUseRtlTheme();
var supportResponsive = EngineContext.Current.Resolve<StoreInformationSettings>().ResponsiveDesignSupported;
}
@helper RenderCategoryLine(CategorySimpleModel category, int level, bool responsiveMobileMenu)
{
<li>
<a href="@Url.RouteUrl("Category", new { SeName = category.SeName })">@category.Name
@if (category.NumberOfProducts.HasValue)
{
<text> </text>@T("Categories.TotalProducts", category.NumberOfProducts.Value)
}
</a>
@{
var levelClass = "";
if (level == 0)
{
levelClass = "firstLevel";
<div class="top-menu-triangle"></div>
}
if (category.SubCategories.Count > 0)
{
if (responsiveMobileMenu)
{
<span class="expand"> </span>
}
<ul class="sublist @levelClass">
@foreach (var subCategory in category.SubCategories)
{
@RenderCategoryLine(subCategory, level + 1, responsiveMobileMenu)
}
</ul>
}
}
</li>
}
<ul class="top-menu">
@Html.Widget("header_menu_before")
@foreach (var category in Model.Categories)
{
@RenderCategoryLine(category, 0, false)
}
@foreach (var topic in Model.Topics)
{
<li><a href="@Url.RouteUrl("Topic", new { SeName = topic.SeName })">@topic.Name</a></li>
}
@if (Model.Categories.Count == 0 && Model.Topics.Count == 0)
{
//no categories or topis to display? in this case let's diplay some default menu items (should we?)
<li><a href="@Url.RouteUrl("HomePage")">@T("HomePage")</a></li>
if (Model.RecentlyAddedProductsEnabled)
{
<li><a href="@Url.RouteUrl("RecentlyAddedProducts")">@T("Products.NewProducts")</a>
</li>
}
<li><a href="@Url.RouteUrl("ProductSearch")">@T("Search")</a> </li>
<li><a href="@Url.RouteUrl("CustomerInfo")">@T("Account.MyAccount")</a></li>
if (Model.BlogEnabled)
{
<li><a href="@Url.RouteUrl("Blog")">@T("Blog")</a></li>
}
if (Model.ForumEnabled)
{
<li><a href="@Url.RouteUrl("Boards")">@T("Forum.Forums")</a></li>
}
<li><a href="@Url.RouteUrl("ContactUs")">@T("ContactUs")</a></li>
}
@Html.Widget("header_menu_after")
</ul>
AFTER
@model TopMenuModel
@using Nop.Core.Domain
@using Nop.Core.Infrastructure
@using Nop.Services.Configuration
@using Nop.Web.Models.Catalog
@{
var engineContext = EngineContext.Current;
var settingService = engineContext.Resolve<ISettingService>();
var storeInformationSettings = engineContext.Resolve<StoreInformationSettings>();
var supportResponsive = storeInformationSettings.ResponsiveDesignSupported;
var isRtl = this.ShouldUseRtlTheme();
var showDefaultMenuItems = settingService.GetSettingByKey<bool>("ShowDefaultMenuItems");
}
@helper RenderCategoryLine(CategorySimpleModel category, int level, bool responsiveMobileMenu)
{
<li>
<a href="@Url.RouteUrl("Category", new { SeName = category.SeName })">@category.Name
@if (category.NumberOfProducts.HasValue)
{
<text> </text>@T("Categories.TotalProducts", category.NumberOfProducts.Value)
}
</a>
@{
var levelClass = "";
if (level == 0)
{
levelClass = "firstLevel";
<div class="top-menu-triangle"></div>
}
if (category.SubCategories.Count > 0)
{
if (responsiveMobileMenu)
{
<span class="expand"> </span>
}
<ul class="sublist @levelClass">
@foreach (var subCategory in category.SubCategories)
{
@RenderCategoryLine(subCategory, level + 1, responsiveMobileMenu)
}
</ul>
}
}
</li>
}
<ul class="top-menu">
@Html.Widget("header_menu_before")
@if (!showDefaultMenuItems)
{
foreach (var category in Model.Categories)
{
RenderCategoryLine(category, 0, false);
}
}
@if (showDefaultMenuItems || (Model.Categories.Count == 0 && Model.Topics.Count == 0))
{
//no categories or topis to display? in this case let's diplay some default menu items (should we?)
<li><a href="@Url.RouteUrl("HomePage")">@T("HomePage")</a></li>
if (Model.RecentlyAddedProductsEnabled)
{
<li><a href="@Url.RouteUrl("RecentlyAddedProducts")">@T("Products.NewProducts")</a>
</li>
}
<li><a href="@Url.RouteUrl("ProductSearch")">@T("Search")</a> </li>
<li><a href="@Url.RouteUrl("CustomerInfo")">@T("Account.MyAccount")</a></li>
if (Model.BlogEnabled)
{
<li><a href="@Url.RouteUrl("Blog")">@T("Blog")</a></li>
}
if (Model.ForumEnabled)
{
<li><a href="@Url.RouteUrl("Boards")">@T("Forum.Forums")</a></li>
}
<li><a href="@Url.RouteUrl("ContactUs")">@T("ContactUs")</a></li>
}
@foreach (var topic in Model.Topics)
{
<li><a href="@Url.RouteUrl("Topic", new { SeName = topic.SeName })">@topic.Name</a></li>
}
@Html.Widget("header_menu_after")
</ul>
Hope this help :)