I'm building some code right now that I think should handle all of your
cases. Since Menu.builder is already concerned with building a menu tree, I
decided that it would be better to allow you to specify a specific item or
group to Menu.builder instead of conflating tree building with the current
Menu.item and Menu.group snippets. Given a SiteMap like:

    val menus =
      Menu(Loc("Home", List("index"), "Home Page")) ::
      Menu(Loc("Viewtest", List("ViewTest", "test"), "View test")) ::
      Menu(Loc("InsecureViewtest", List("Insecure", "test"), "Insecure View
test")) ::
      Menu(Loc("SelectTest", List("select"), "asm select test")) ::
      Menu(Loc("Help", List("help", "index"), "Help", LocGroup("help")),
       Menu(Loc("About", List("help", "about"), "About", LocGroup("help"))),
       Menu(Loc("Version", List("help", "version"), "Version",
LocGroup("help")))) :: Nil

You can render just the Help tree with:

<lift:Menu.builder item="Help" expandAll="true" />

Which will render something like:

<ul><li><a href="/testthis/help/
<view-source:http://localhost:9090/testthis/help/>">Help</a><ul><li><a
href="/testthis/help/about
<view-source:http://localhost:9090/testthis/help/about>">About</a></li><li><a
href="/testthis/help/version
<view-source:http://localhost:9090/testthis/help/version>">Version</a></li></ul></li></ul>

Similarly, you can use a group attribute:

<lift:Menu.builder group="help" expandAll="true" />

But notice that this won't deduplicate entries, so we would render something
like:

<ul><li><a href="/testthis/help/
<view-source:http://localhost:9090/testthis/help/>">Help</a><ul><li><a
href="/testthis/help/about
<view-source:http://localhost:9090/testthis/help/about>">About</a></li><li><a
href="/testthis/help/version
<view-source:http://localhost:9090/testthis/help/version>">Version</a></li></ul></li><li><a
href="/testthis/help/about
<view-source:http://localhost:9090/testthis/help/about>">About</a></li><li><a
href="/testthis/help/version
<view-source:http://localhost:9090/testthis/help/version>">Version</a></li></ul>

This is currently checked in on the wip-dcb-menu-addons branch:

http://github.com/dpp/liftweb/tree/wip-dcb-menu-addons

Thoughts?

Derek



On Mon, Jun 8, 2009 at 5:49 PM, glenn <gl...@exmbly.com> wrote:

>
> Yes,
>
> I would like the expandAll behavior to work for groups and for non-
> root siteMaps.
> Here's a specific use-case. The MenuWidget in the lift-widgets package
> just passes everything
> through  as
>
> def render : NodeSeq = {
>    head ++ <lift:Menu.builder expandAll="true" top:class=
> {style.toString} />
>  }
>
> So, even though the MenuWidget object has factory methods
> for using a  non-root siteMap, only the root siteMap is ever used.
> That's
> because Menu.builder calls a private function renderWhat, like so:
>
> val toRender = renderWhat(expandAll)
>
> which iterates through the root siteMap. There is no way, really, to
> subclass that
> to use a different siteMap.
>
> The problem with the Menu.group snippet is that it just works off the
> named group in
> the root siteMap, creating a parent node, but not the kids.
>
> It would be nice to use MenuWidget, or some subclass, to create a
> superfish-style
> nav-bar or horizontal menu for groups or non-root siteMaps just as
> easily as for the
> entire root siteMap.
>
> Glenn...
>
> On Jun 8, 3:51 pm, Joe Wass <j...@folktunefinder.com> wrote:
> > What I really wanted was a menu group. Doing things in groups has
> > solved my particular question.
> >
> > Glenn, can you not just use groups? Do you need the hierarchal
> > behaviour of nested menus?
> >
> > Joe
> >
> > On Jun 8, 10:24 pm, glenn <gl...@exmbly.com> wrote:
> >
> > > I have a similar request: namely, being able to apply expandAll="true"
> > > attribute
> > > not just to <lift:Menu.builder.../>
> >
> > > but to <lift:Menu.group name="mygroup"/> and <lift:Menu.item
> > > name="myMenu"/>, or, as Joe requests below,
> >
> > > to any siteMap that is not the root siteMap.
> >
> > > Glenn...
> >
> > > On Jun 8, 2:06 pm, Joe Wass <j...@folktunefinder.com> wrote:
> >
> > > > Sorry for yet another menu question. I have scoured this list first,
> I
> > > > promise!
> >
> > > > I'm trying to do something I think is quite simple:
> >
> > > > Two [or any nuumber of] menus (with children). Two different
> > > > templates. One menu and children shows up on one template, one shows
> > > > up on another. They are each nested menus (i.e. I have two Menus,
> each
> > > > with child menu items). You can directly go to any page you want, but
> > > > only certain Menu items show up on certain templates.
> >
> > > > I had thought I could put a guard (the last argument of the Loc) to
> > > > only show a menu when the request string contains part of the path,
> > > > but of course, that prevents you from navigating there in the first
> > > > place so that's out.
> >
> > > > I've seen this post :
> http://groups.google.com/group/liftweb/browse_thread/thread/dbdf6a17b...
> >
> > > > but it doesn't quite do what I want: I want to be able to show a
> whole
> > > > Menu at a time, not have to list each individual item in the
> template.
> > > > I'd like to do something like this:
> >
> > > > <lift:Menu.builder menuName="menu_name"/>
> >
> > > > Any ideas? I'll accept a hack, I'm short on time!
> >
> > > > Bonus marks: how do you set a menu to be expanded by default (without
> > > > having to be on the root node's page)? I saw `expandAll="true"`
> > > > somewhere, but that doesn't do anything...
> >
> > > > Thanks!
> >
> > > > Joe
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to