Reputation: 15702
Since I have to work on an existing database, I've written my own User
type for my App. It works fine, but I have trouble wiring in the templates for it.
The ProtoUser
trait, which I used, provides a lot of the functionality, even an own sitemap
method. There's nothing wrong with that one, but I need it to be Hidden
.
I've then tried to just make my own Menu
instances for them. They are exactly like the ones defined in the ProtoUser
trait, but they simply don't work.
This is my current SiteMap. The full code is here here.
val entries = List(
Menu.i("Home") / "index" >> Hidden,
Menu.i("Branches") / "branches",
Menu.i("Ponies") / "ponies",
Menu.i("Profile") / "profile" >> If(() => User.loggedIn_?, "You must be logged in"),
/* Menu.i("Login") / "login" >> Hidden >> Template(() => User.wrapIt(User.login)) >> If(() => User.notLoggedIn_?, "Already logged in"),
Menu.i("Logout") / "logout" >> Hidden >> Template(() => User.wrapIt(User.logout)) >> If(() => User.loggedIn_?, "You must be logged in"),
Menu.i("Sign Up") / "signUp" >> Hidden >> Template(() => User.wrapIt(User.signup)) >> If(() => User.notLoggedIn_?, "Already logged in"),*/
Menu(Loc("Static", Link(List("static"), true, "/static/index"),
"Static Content", Hidden))
) ::: User.sitemap
Maybe someone can help me on how to hide that User.sitemap
? Or how it's supposed to be done, I am used to framework with explicit routing.
Upvotes: 1
Views: 172
Reputation: 6219
Check the class ProtoUser
of the the lift framework under net.liftweb.proto
where the menu items are defined.
In your User
class you can override those menu items, for instance:
override protected def editUserMenuLocParams: List[LocParam[Unit]] =
Hidden :: //hides it but still reachable
Template(() => wrapIt(editFunc.map(_()) openOr edit)) ::
testLogginIn ::
Nil
or to deactivate it outright:
override def editUserMenuLoc: Box[Menu] = Empty //not reachable
Then in your Boot
write something like:
def sitemap() = SiteMap(
Menu("Home") / "index" >> Hidden >> User.AddUserMenusAfter)
Upvotes: 1