Get List of Location's Parent's Children

6 views
Skip to first unread message

lmorroni

unread,
Aug 27, 2010, 2:20:10 PM8/27/10
to Lift
I'm still a novice. I took Menu.scala and modified it to do a few
things I need. One of my goals is to take the current loc, find the
top level loc and then return a NodeSeq of all the first level
children of that top level node. My menus only have two levels.
Maybe I can do this with the existing Menu snippet but I could not
figure it out. I think my question boils down to this: Given any
loc, how do I obtain a NodeSeq representation of all items in the
second level of it's breadCrumb tree? The dead end I always seem to
hit is taking a list of MenuItems and generating the proper NodeSeq
from it.
I called my new function currentKids. For instance:

<ul>
<lift:MorroniMenu.currentKids />
</ul>

And the function(doesn't compile)
def currentKids(template: NodeSeq): NodeSeq = {
val toBind = if ((template \ "bind").filter(_.prefix ==
"menu").isEmpty)

<xml:group><menu:bind/> </xml:group>
else template
val attrs = S.prefixedAttrsToMetaData("a")

for (request <- S.request.toList;
siteMap <- LiftRules.siteMap.toList;
currentLoc <- request.location.toList;
loc <- currentLoc.breadCrumbs.toList take 1
)

yield {
val a = //need This still

Group(bind("menu", toBind, "bind" -> a))
}
}

Any insight from the Jedis would be appreciated.
Larry

lmorroni

unread,
Aug 27, 2010, 3:03:53 PM8/27/10
to Lift
Sorry, the front end of the snippet is actually:
<ul>
<lift:MorroniMenu.currentKids>
<li>
<menu:bind/>
</li>
</lift:MorroniMenu.currentKids>
</ul>
Reply all
Reply to author
Forward
0 new messages