Handing Movie Navigation
Setting Navigation Item Title and Icon
When Sergen generated code for Movie table, it also created a navigation item entry. In Serene, navigation items are created with special assembly attributes.
Open MoviePage.cs in the same folder, on top of it you'll find this line:
[assembly:Serenity.Navigation.NavigationLink(int.MaxValue, "MovieDB/Movie",
typeof(MovieTutorial.MovieDB.Pages.MovieController))]
namespace MovieTutorial.MovieDB.Pages
{
//...
First argument to this attribute is display order for this navigation item. As we only have one navigation item in Movie category yet, we don't have to mess with ordering yet.
Second parameter is navigation title in "Section Title/Link Title" format. Section and navigation items are seperated with a slash (/).
Lets change it to Movie Database/Movies.
[assembly:Serenity.Navigation.NavigationLink(int.MaxValue, "Movie Database/Movies",
typeof(MovieTutorial.MovieDB.Pages.MovieController), icon: "icon-camrecorder")]
namespace MovieTutorial.MovieDB.Pages
{
//..
We also changed navigation item icon to icon-camcorder. Serene template has two sets of font icons, Simple Line Icons and Font Awesome. Here we used a glyph from simple line icons set.
To see list of simple line icons and their css classes, visit link below:
http://thesabbir.github.io/simple-line-icons/
FontAwesome is available here:
https://fortawesome.github.io/Font-Awesome/icons/
There is also a page in Serene under Theme Samples / UI Elements / Icons containing a list of these icon sets.
Ordering Navigation Sections
As our Movie Database section is auto generated last, it is displayed at the bottom of navigation menu.
We'll move it before Northwind menu.
As we saw recently, Sergen created a navigation item in MoviePage.cs. If navigation items are scattered through pages like this, it would be hard to see the big picture (list of all navigation items) and order them easily.
So we move it to our central location which is at MovieTutorial.Web/Modules/Common/Navigation/NavigationItems.cs.
Just cut the below lines from MoviePage.cs:
[assembly:Serenity.Navigation.NavigationLink(int.MaxValue, "Movie Database/Movies",
typeof(MovieTutorial.MovieDB.Pages.MovieController), icon: "icon-camrecorder")]
Move it into NavigationItems.cs and modify it like this:
using Serenity.Navigation;
using Northwind = MovieTutorial.Northwind.Pages;
using Administration = MovieTutorial.Administration.Pages;
using MovieDB = MovieTutorial.MovieDB.Pages;
[assembly: NavigationLink(1000, "Dashboard", url: "~/", permission: "",
icon: "icon-speedometer")]
[assembly: NavigationMenu(2000, "Movie Database", icon: "icon-film")]
[assembly: NavigationLink(2100, "Movie Database/Movies",
typeof(MovieDB.MovieController), icon: "icon-camcorder")]
[assembly: NavigationMenu(8000, "Northwind", icon: "icon-anchor")]
[assembly: NavigationLink(8200, "Northwind/Customers",
typeof(Northwind.CustomerController), icon: "icon-wallet")]
[assembly: NavigationLink(8300, "Northwind/Products",
typeof(Northwind.ProductController), icon: "icon-present")]
// ...
Here we also declared a navigation menu (Movie Database) with film icon. When you don't have an explicitly defined navigation menu, Serenity implicitly creates one, but in this case you can't order menu yourself, or set menu icon.
We assigned it a display order of 2000 so this menu will display just after Dashboard link (1000) but before Northwind menu (8000).
We assigned our Movies link a display order value of 2100 but it doesn't matter right now, as we have only one navigation item under Movie Database menu yet.
First level links and navigation menus are sorted according to their display order first, then second level links among their siblings.
Here is how it looks like after these changes:
Troubleshooting Some Issues with Visual Studio
In case you didn't notice already, Visual Studio doesn't let you modify code while your site is running. Also your site stops when you stop debugging, so you can't keep browser window open and refresh after rebuilding.
To solve this issue, we need to disable Edit And Continue (have no idea why).
Right Click MovieTutorial.Web project, click Properties, in the Web tab, uncheck Enable Edit And Continue under Debuggers.
Unfortunately, the solution above stops works in Visual Studio 2015 Update 2. Only workaround so far seems like starting without debugging, e.g. Ctrl+F5 instead of F5.
Also, on your site, top blue progress bar (which is a Pace.js animation), keeps running all the time like it is still loading something. It is thanks to the Browser Link feature of Visual Studio. To disable it, locate its button in Visual Studio toolbar that looks like a refresh button (next to play icon with browser name like Chrome), click dropdown and uncheck Enable Browser Link.
It's also possible to disable it with a web.config setting
<appsettings>
<add key="vs:EnableBrowserLink" value="false" />
</appsettings>
Serene 1.5.4 and later has this in web.config by default, so you might not experience this issue