Building a layered menu

19 views
Skip to first unread message

Scott

unread,
Aug 18, 2008, 4:23:25 PM8/18/08
to liftweb
Hello,

Wondering if anyone can help explain if and how you create a layered
menu? By layered menu, I mean something like this:

menu 1
menu 2
submenu 1
submenu 2
menu 3
menu 4

I have seen the kids identifier in the Menu constructor, but I can't
seem to find anything about how to then access the "kids" on the page
that you want them displayed on.

Thanks,
Scott

David Pollak

unread,
Aug 18, 2008, 10:02:28 PM8/18/08
to lif...@googlegroups.com
I thought that your example was implemented... turns out there was a little work on the Lift innards required.

In Boot:

object MenuInfo {
  import Loc._

  def menu: List[Menu] =  Menu(Loc("home", List("index"), "Home")) ::
  Menu(Loc("xml fun", List("xml_fun"), "XML Fun")) ::
  Menu(Loc("chat", List("chat"), "Comet Chat")) ::
  Menu(Loc("database", List("database"), "Database")) ::
  Menu(Loc("ajax", List("ajax"), "AJAX Samples")) ::
  Menu(Loc("ajax form", List("ajax-form"), "AJAX Form")) ::
  Menu(Loc("json", List("json"), "JSON Messaging")) ::
  Menu(Loc("ws", List("ws"), "Web Services")) ::
  Menu(Loc("simple", Link(List("simple"), true, "/simple/index"),
       "Simple Forms")) ::
  Menu(Loc("lang", List("lang"), "Localization")) ::
  Menu(Loc("menu_top", List("menu", "index"), "Menus"),
       Menu(Loc("menu_one", List("menu", "one"), "First Submenu")),
       Menu(Loc("menu_two", List("menu", "two"), "Second Submenu (has more)"),
        Menu(Loc("menu_two_one", List("menu", "two_one"),
             "First (2) Submenu")),
        Menu(Loc("menu_two_two", List("menu", "two_two"),
             "Second (2) Submenu"))
      ),
       Menu(Loc("menu_three", List("menu", "three"), "Third Submenu")),
       Menu(Loc("menu_four", List("menu", "four"), "Forth Submenu"))
     ) ::
  Menu(Loc("file_upload", List("file_upload"), "File Upload")) ::
  Menu(Loc("wiki", Link(List("wiki"), true, "/wiki/HomePage"), "Wiki")) ::
  Menu(Loc("guess", List("guess"), "Number Guessing")) ::
  Menu(Loc("count", List("count"), "Counting")) ::
  Menu(Loc("login", Link(List("login"), true, "/login/index"),
       <xml:group>Requiring Login <strike>SiteMap</strike></xml:group>)) ::
  Menu(Loc("arc", List("arc"), "Arc Challenge #1")) ::
  Menu(Loc("lift", ExtLink("http://liftweb.net"),
     <xml:group><i>Lift</i> project home</xml:group>)) ::
  Nil
}

   LiftRules.setSiteMap(SiteMap(MenuInfo.menu :_*))

Note that some Menus (e.g. "menu_one") are nested.  This will result in a nested display of the menus.  I've also updated sites/example to show this off.

Thanks,

David
--
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

TylerWeir

unread,
Aug 19, 2008, 7:30:10 AM8/19/08
to liftweb
Dpp, you rock harder than a hard rock rock band.

I can toss my half-assed version that I wrote yesterday for this.
Gold!

On Aug 18, 10:02 pm, "David Pollak" <feeder.of.the.be...@gmail.com>
wrote:
> Collaborative Task Managementhttp://much4.us

David Pollak

unread,
Aug 19, 2008, 11:47:18 AM8/19/08
to lif...@googlegroups.com
On Tue, Aug 19, 2008 at 4:30 AM, TylerWeir <tyler...@gmail.com> wrote:

Dpp, you rock harder than a hard rock rock band.

Glad you like this.  It traces its roots back to SmartMode, a Java-based web framework I did earlier this decade.  The real good ideas in SmartMode belong to Dani Pletter and Jon Levine... two excellent web developers.
 



--
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Reply all
Reply to author
Forward
0 new messages