Skip to content

Commit 199f2a4

Browse files
committed
Highlighted active menu for MPA.
1 parent c5166e4 commit 199f2a4

File tree

10 files changed

+13
-9
lines changed

10 files changed

+13
-9
lines changed

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebMpa/App_Start/MySpaProjectNavigationProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace MySpaProject.WebMpa
77
/// This class defines menus for the application.
88
/// It uses ABP's menu system.
99
/// When you add menu items here, they are automatically appear in angular application.
10-
/// See .cshtml and .js files under App/Main/views/layout/header to know how to render menu.
10+
/// See _TopMenu.cshtml file under Views/Shared/ to know how to render menu.
1111
/// </summary>
1212
public class MySpaProjectNavigationProvider : INavigationProvider
1313
{

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebMpa/Controllers/LayoutController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ public LayoutController(IUserNavigationManager userNavigationManager, ILocalizat
1717
}
1818

1919
[ChildActionOnly]
20-
public PartialViewResult TopMenu()
20+
public PartialViewResult TopMenu(string activeMenu = "")
2121
{
2222
var model = new TopMenuViewModel
2323
{
24-
MainMenu = _userNavigationManager.GetMenu("MainMenu", CurrentSession.UserId)
24+
MainMenu = _userNavigationManager.GetMenu("MainMenu", CurrentSession.UserId),
25+
ActiveMenuItemName = activeMenu
2526
};
2627

2728
return PartialView("_TopMenu", model);

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebMpa/Models/Layout/TopMenuViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ namespace MySpaProject.WebMpa.Models.Layout
55
public class TopMenuViewModel
66
{
77
public UserMenu MainMenu { get; set; }
8+
9+
public string ActiveMenuItemName { get; set; }
810
}
911
}

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebMpa/MySpaProject.WebMpa.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@
318318
<Content Include="packages.config" />
319319
<Content Include="Views\About\Index.cshtml" />
320320
<Content Include="Views\Shared\_TopBar.cshtml" />
321-
<Content Include="Views\Shared\_LanguageSelection.cshtml" />
322-
<Content Include="Views\Shared\_TopMenu.cshtml" />
321+
<Content Include="Views\Layout\_LanguageSelection.cshtml" />
322+
<Content Include="Views\Layout\_TopMenu.cshtml" />
323323
<Content Include="Scripts\toastr.min.js.map" />
324324
<Content Include="Views\Shared\Error.cshtml" />
325325
<None Include="Web.Debug.config">

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebMpa/Views/About/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ViewBag.CurrentPage = "About";
2+
ViewBag.ActiveMenu = "About"; //The menu item will be active for this page.
33
}
44
<div>
55
<h1><img src="~/images/abp-logo.png" style="padding-right: 10px;" />@string.Format(L("AboutFormat"), "ASP.NET Boilerplate")</h1>

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebMpa/Views/Home/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ViewBag.CurrentPage = "Home";
2+
ViewBag.ActiveMenu = "Home"; //The menu item will be active for this page.
33
}
44
<div>
55
<h1>@L("WellcomeMessage")!</h1>

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebMpa/Views/Shared/_TopMenu.cshtml renamed to Templates/All-In-One-Template/MySpaProject/MySpaProject.WebMpa/Views/Layout/_TopMenu.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@model MySpaProject.WebMpa.Models.Layout.TopMenuViewModel
22
@foreach (var menuItem in Model.MainMenu.Items)
33
{
4-
<li class="@(ViewBag.CurrentPage == menuItem.Name ? "active" : "")">
4+
<li class="@(Model.ActiveMenuItemName == menuItem.Name ? "active" : "")">
55
<a href="@menuItem.Url">
66
@if (!string.IsNullOrWhiteSpace(menuItem.Icon))
77
{

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebMpa/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<script src="@Url.Content("~/Scripts/others/html5shiv.js")"></script>
3030
<script src="@Url.Content("~/Scripts/others/respond.min.js")"></script>
3131
<![endif]-->
32+
3233
@Scripts.Render("~/Bundles/vendor/js/top")
3334

3435
</head>

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebMpa/Views/Shared/_TopBar.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</div>
1212
<div class="collapse navbar-collapse">
1313
<ul class="nav navbar-nav">
14-
@Html.Action("TopMenu", "Layout")
14+
@Html.Action("TopMenu", "Layout", new { activeMenu = ViewBag.ActiveMenu })
1515
</ul>
1616
<ul class="nav navbar-nav navbar-right">
1717
@Html.Action("LanguageSelection", "Layout")

0 commit comments

Comments
 (0)