Styling Menu.builder's Output

79 views
Skip to first unread message

Peter Robinett

unread,
Jul 5, 2010, 1:05:03 PM7/5/10
to Lift
Hi all,

Menu.builder is a huge help and with the ability to set the css
classes and change from an unordered list to the tags of my choosing I
can do just about anything. BUT, I'm having a hard time figuring out
how to not display the links in the sort of tree structure used by
default and instead put all the top level entries on one line and the
current top level item's submenus on the next line. Think the standard
two level horizontal navigation elements you see one many sites,
including on Google Groups (kind of).

I think I should be able to do this all in CSS but absolute
positioning leads to wonky results and relative positioning leaves a
hole in my line of top level elements. Has anyone wanted to do this
before? It seems that what I want to do isn't THAT unusual.

I've gotten close with the following but it doesn't work in all cases:

<lift:Menu.builder top:id="menu" outer_tag="div" inner_tag="div"
ul:class="menuSection" li:class="menuItem" li_item:id="selectedMenu"
li_item:class="menuSection" li_path:class="parentMenu" />

.menuItem {
margin-left: 2px;
margin-right: 2px;
}

.menuSection, .menuItem, .parentMenu {
float: left;
}

#selectedMenu .menuSection, .parentMenu .menuSection {
position: absolute;
float: left;
}

Perhaps the alternative is to just output the selected submenu after
the top level menus, maybe using Menu.item and Menu.group to help. In
that case, how do I name a group when using the new Menu DSL's
'submenus ( ... )' syntax?

Thanks,
Peter

Mratin

unread,
Jul 6, 2010, 9:47:10 AM7/6/10
to Lift
We've had a similar problem on our site and we haven't found a good
solution to it yet unfortunately.

I would also be very interested in finding a better solution to this
problem.

Cheers,
/Martin

Peter Robinett

unread,
Jul 6, 2010, 8:19:37 PM7/6/10
to Lift
I haven't looked into it much but I think that it shouldn't be too
hard to access the current menu and group and have corresponding
snippets like <Menu:currentItem /> and <Menu:currentGroup /> and
<Menu:currentSubgroup />. There's an expandAll option for Menu.builder
but it's not clear to me whether if it's false the submenus are
_never_ expanded. I don't think so. If not, perhaps the undocumented
"level" attribute would help? Could someone who knows the internals of
Menu.builder (David?) clarify?

Would something like this help you, Martin?
<Menu:topGroup />
<Menu:currentSubgroup />

Peter

Mratin

unread,
Jul 7, 2010, 1:33:27 AM7/7/10
to Lift

> Would something like this help you, Martin?
> <Menu:topGroup />
> <Menu:currentSubgroup />

Yes, something like that would be great.

Martin

Derek Chen-Becker

unread,
Jul 7, 2010, 9:04:44 AM7/7/10
to lif...@googlegroups.com
The "expandAll" option just makes all menus with submenus expand whether or not they're the current menu. Without that option, the current Menu will still expand its children.

As for your issue, let me make sure I understand it correctly. You want one set of elements to show all top-level menus, and then have a second set of elements for the current menu's children? That's not really supported, although you could probably do it with the Menu:group snippet to an extent. I don't think it would be too hard to add a Menu.currentChildren snippet and an "expandNone" option to the current builder to suppress child menus.

Derek

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


Mratin

unread,
Jul 7, 2010, 9:23:41 AM7/7/10
to Lift
> As for your issue, let me make sure I understand it correctly. You want one
> set of elements to show all top-level menus, and then have a second set of
> elements for the current menu's children?

I can't speak for Peter, but what you describe is exactly what I need
to achieve.
Right now I have a hack based on menu groups, but it's not very
convenient and pretty ugly imo.

/Martin
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com >
> > .

Derek Chen-Becker

unread,
Jul 7, 2010, 9:28:22 AM7/7/10
to lif...@googlegroups.com
Please open an issue and assign it to me (not sure if you can in Assembla, but hey). I may not get to it today, but I should be able to hammer it out this week since I'm working on other Menu stuff anyway.

Derek

To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.

Martin

unread,
Jul 7, 2010, 9:50:31 AM7/7/10
to Lift
Thanks a lot, Derek!

I have posted the ticket #572 and assigned it to you. I hope that my
brief description (actually your description ;-) ) is enough to
implement the feature.

Cheers,
Martin
> > <liftweb%2Bunsu...@googlegroups.com<liftweb%252Bunsubscribe@googlegroup s.com>>

Timothy Perrett

unread,
Jul 7, 2010, 11:47:38 AM7/7/10
to lif...@googlegroups.com
He should be able to assign it to you; I think watchers can do that. If not, just leave it open and one of us will assign it etc

Cheers, Tim

Peter Robinett

unread,
Jul 7, 2010, 12:08:10 PM7/7/10
to Lift
Seconded, thanks Derek. That's exactly what I want.

Peter

David Pollak

unread,
Jul 7, 2010, 12:40:27 PM7/7/10
to lif...@googlegroups.com
I think you want the "level" attribute: <lift:Menu.builder level="1"/> (the top level menu items) <lift:Menu.builder level="2"/> (the children of the current top level menu item)

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

Peter Robinett

unread,
Jul 7, 2010, 1:01:50 PM7/7/10
to Lift
Oh man, David, so simple! =) Unfortunately, only part of the solution
is there: <lfit:Menu.builder level="1"> is the children of the current
top level item. Trying other levels, level 0 seems to be the normal
builder output (ie top level plus the children of the currently
selected item), while level 2 doesn't give anything as I don't have
anything nested that deep. Am I missing something?

Thanks!

Peter
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com >
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/liftweb?hl=en.
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890

David Pollak

unread,
Jul 7, 2010, 1:05:36 PM7/7/10
to lif...@googlegroups.com
On Wed, Jul 7, 2010 at 10:01 AM, Peter Robinett <pe...@bubblefoundry.com> wrote:
Oh man, David, so simple! =) Unfortunately, only part of the solution
is there: <lfit:Menu.builder level="1"> is the children of the current
top level item. Trying other levels, level 0 seems to be the normal
builder output (ie top level plus the children of the currently
selected item), while level 2 doesn't give anything as I don't have
anything nested that deep. Am I missing something?

Sorry... it was an off-by one error.  level="0" is top level.  level="1" is the next level down... and so on.  And add expand="false" to that to only give you the current level.
 
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890

Peter Robinett

unread,
Jul 7, 2010, 1:08:33 PM7/7/10
to Lift
Thanks, that did it!
> > <liftweb%2Bunsu...@googlegroups.com<liftweb%252Bunsubscribe@googlegroup s.com>>

Derek Chen-Becker

unread,
Jul 7, 2010, 1:10:07 PM7/7/10
to lif...@googlegroups.com
Neither "level" nor "expand" are documented in ScalaDocs. I'll go ahead and add them if that's OK.

To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.

David Pollak

unread,
Jul 7, 2010, 1:11:40 PM7/7/10
to lif...@googlegroups.com
On Wed, Jul 7, 2010 at 10:10 AM, Derek Chen-Becker <dchen...@gmail.com> wrote:
Neither "level" nor "expand" are documented in ScalaDocs. I'll go ahead and add them if that's OK.

Please do.
 



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890

Martin

unread,
Jul 7, 2010, 4:28:04 PM7/7/10
to Lift
Great, so the feature we both were looking for actually already
exists. I'm very pleased with that. Thank you all!

/Martin

On 7 Juli, 19:11, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> >> > > <liftweb%2Bunsu...@googlegroups.com<liftweb%252Bunsubscribe@googlegroup s.com>

Peter Robinett

unread,
Jul 8, 2010, 3:06:18 AM7/8/10
to Lift
I've updated the wiki page.
Reply all
Reply to author
Forward
0 new messages