Liftweb Menu customization

前端 未结 4 698
悲哀的现实
悲哀的现实 2021-02-04 18:26

I want to create a menu that looks like:

HOME | FOO | BAR | ABOUT | CONTACT

How might I go about doing this?

Here is what I have tried:

&         


        
4条回答
  •  被撕碎了的回忆
    2021-02-04 19:16

    There might be a cleaner way to do this. Once you've declared the urls in your sitemap, you can pretty much use them as regular links in your template. You would write them as pure html.

    In Boot.scala:

    val menus = List(
      Menu(Loc("home", List("index"), "Home")),
      Menu(Loc("foo", List("foo"), "Foo")),
      Menu(Loc("bar", List("bar"), "Bar")),
      Menu(Loc("about", List("about"), "About")),
      Menu(Loc("contact", List("contact"), "Contact"))
    )
    LiftRules.setSiteMap(SiteMap(menus: _*))
    

    In your template, e.g. index.html:

    
    

    Or as said Debilski, you can also call each menu item by their name. It would be more Lift-iesc.

    
    

    You can then add any style you want in an external stylesheet file or inside the page.

提交回复
热议问题