Menus are an important part of an application. They show a hierarchical structure and how the application is organized. Users will use them to navigate through the application.
Lift does offer a good built-in snippet for creating menus, as I briefly said before. In this recipe, I'll show you how to use this snippet to create complex menu structures, and how to render them with fine-grained control.
Create a new project and add the following code in the Boot
class to create the SiteMap:
Val isAdmin_? = If(() => { S.param("admin").flatMap(asBoolean).openOr(false) }, () => RedirectWithState("/", MessageState( "Authorized personnel only" -> NoticeType.Warning)) ) val entries = List( Menu.i("Home") / "index" >> LocGroup("content"), // the simple way to declare a menu Menu("Admin") / "admin" >> Hidden submenus( Menu(Loc("List", List("list"), "List Contacts", isAdmin_?, LocGroup("admin"))), Menu(Loc("Create", List("create...