Liftweb Menu Customization

Name and location of snippet for Menu with param in LiftWeb?

It was actually the obvious answer. The template name is obtained from the path and the snippet can be whatever you want as long as you call it from the template xml.

I need to get used to all this convention over configuration :) However it would be nice for someone to tell you what is the convention.

Scala | Lift | How to make across menu

This is more a CSS question than a Lift question. The HTML produced for the menu looks something like this:

<div class="column span-6 colborder sidebar">
<hr class="space" />
<ul>
<li> <span>Home</span></li>
<li> <a href="/user_mgt/login">Login</a></li>
<li> <a href="/user_mgt/sign_up">Sign Up</a></li>
<li> <a href="/user_mgt/lost_password">Lost Password</a></li>
<li> <a href="/search">Search</a></li>
</ul>
...
</div>

I.e., about as vanilla as possible, so it's very easy to add some CSS to create a horizontal menu out of the list—see for example the "Horizontal lists" examples on Listamatic.

It would be simplest just to add the CSS code to the header in src/main/webapp/templates-hidden/default.html, but you could also use your own separate CSS file without too much fuss.

In Lift, changing the way Menu.param behaves

As you can see, you have two menu references to same path:

// Menu.i("Autobiography") / "journal", // Works if I comment out the next line.

val menu = Menu.param[AutobiographyPage](
​"Autobiography", "Autobiography",
pageName => Full(AutobiographyPage(​pageName)),
ap => ap.pageName) / "journal"

They both match http://localhost/journal, and have same menu id "Autobiography", that's why it does not work.

You may try to change menu id "Autobiography" in AutobiographyPageMenu.param to see if it work.

Highlight current menu item lift

I'm assuming you're using the sitemap for your menu.

When rendering the menu with the Menu.builder snippet you can use additional parameters to further tweak the menu. This example will render only the first level of the menu and adds class current to the menu item if it's the current page.

designer friendly example:

<div class="lift:Menu.builder?level=0;expand=false;li_item:class=current"></div>

or

<lift:Menu.builder  li_item:class="selected" level="0" expand="false" />

for more details see the lift wiki: http://www.assembla.com/wiki/show/liftweb/SiteMap

Liftweb eager_eval and inserting html from db

I don't know if you copied your template code over or re-typed it, but there's a syntax error:

<div class="lift:firstSnippet.content?eager_eval=true">
<p>Some text</p>
<div class='lift:secondSnippet.showAddNewForm>'></div>
</div>

Note the > at the end of secondSnippet.showAddNewForm>

I think it should read:

<div class="lift:firstSnippet.content?eager_eval=true">
<p>Some text</p>
<div class='lift:secondSnippet.showAddNewForm'></div>
</div>

Please try that and see if it makes a difference.

Liftweb submenus with Loc definition

I believe you just pass the submenus as the second parameter to Menu. So:

val AdminLoginRequired = User.loginFirst
val sitemap = List(
Menu(Loc("Home", "index" :: Nil, "Home")),
Menu(
Loc("Admin", "admin" :: Nil, "Admin", AdminLoginRequired, LocGroup("admin")),
admin_sitemap: _*
)
) ::: Customer.menus ::: User.menus ::: Product.menus

However you can convert the old "direct" format to the new dsl format. Assuming you don't need to localize the menu labels, and you don't care about the menus' internal names:

val sitemap = List(
Menu("Home") / "index",
Menu("Admin" / "admin" >> AdminLoginRequired >> LocGroup("admin") submenus (admin_sitemap: _*)
)) ::: Customer.menus ::: User.menus ::: Product.menus

To make the label localizable, use Menu.i instead of plain Menu, and to specify the internal name pass it first, as in Menu("MenuHome", "Home"). Apparently you can't do that with Menu.i (I guess no one thought of it).



Related Topics



Leave a reply



Submit