Hi,
I have one solution for you :)
Following are steps to do it:
- Under "Themes/DefaultClean/Views/Shared" folder.
Create a new partial view named "_SeparatedCategoryNavigation.cshtml".
- Inside the created partial view. Paste following code:
@using Nop.Core.Infrastructure
@using Nop.Services.Catalog
@{
var categoryService = EngineContext.Current.Resolve<ICategoryService>();
var allCategories = categoryService.GetAllCategories();
}
@helper RenderCategoryLine(int parentCategoryId)
{
var categoryService = EngineContext.Current.Resolve<ICategoryService>();
var childCategories = categoryService.GetAllCategoriesByParentCategoryId(parentCategoryId);
if (childCategories.Any())
{
foreach (var childCategory in childCategories)
{
<li>
<a href="@Url.RouteUrl("Category", new { SeName = childCategory.ToModel().SeName })">@childCategory.Name</a>
</li>
}
}
}
@if (allCategories.Any())
{
foreach (var category in allCategories)
{
if (category.ParentCategoryId == 0)
{
<div class="block">
<div class="title">
<a href="@Url.RouteUrl("Category", new { SeName = category.ToModel().SeName })">
<strong>@category.Name</strong>
</a>
</div>
<div class="listbox">
<ul class="list">
@RenderCategoryLine(category.Id)
</ul>
</div>
</div>
}
}
}
- Finally, render this partial view inside your desired page.
For example, I will render it inside "_ColumnsThree.cshtml" view, like this:
BEFORE
@Html.Action("PollBlock", "Poll", new { systemKeyword = "LeftColumnPoll" })
@Html.Widget("left_side_column_after")
AFTER
@Html.Action("PollBlock", "Poll", new { systemKeyword = "LeftColumnPoll" })
@Html.Partial("_SeparatedCategoryNavigation")
@Html.Widget("left_side_column_after")
Hope this help :)