Multiple parameters Menu.param

19 views
Skip to first unread message

Nataly Nanda Huanca Patzi

unread,
Jun 19, 2015, 11:06:05 AM6/19/15
to lif...@googlegroups.com
Hi to all, I need your help

I need create a menu of this form:

myweb.com/idiom/category/subcategory1/subcategory2/.../subcategoryN

right now I put / * for each parameter, but now i don't know how many parameters it will have, how can I setting this?
if I obtain a List of String for create the url when the first string is the idiom and the last string is the subcategoryN

I hope you can help me.

Antonio Salazar Cardozo

unread,
Jun 19, 2015, 2:15:16 PM6/19/15
to lif...@googlegroups.com, nataly...@genso.com.bo
You should use / ** when you get to a point where you don't know what's next. Something
like:

Menu.params[Category](
  "category", "category",
  findCategory _,
  _.uriPath
)

Where:

def findCategory(hierarchy: List[String]): Box[Category] = {
  // hierarchy is now List("subcategory1", "subcategory2", ..., "subcategoryN")
}

And:

case class Category(...) {
  def uriPath: List[String] = {
    // something that returns List("subcategory1", "subcategory2", ..., "subcategoryN")
  }
}

Hope that helps!
Thanks,
Antonio

Nataly Nanda Huanca Patzi

unread,
Jun 19, 2015, 3:41:36 PM6/19/15
to lif...@googlegroups.com, nataly...@genso.com.bo
Hi Antonio, thanks so much.

I made this:

val menuViewFrontEnd = Menu.params[(Language,Category)]("ViewCategory", "ViewCategory", categoryFrontEnd(_),
    getListMenu(_)) / ** >> TemplateBox(() => Templates("category" :: Nil)) >> Hidden

def categoryFrontEnd(ids: List[String]): Box[(Language, Category)] = {
     Category.findByLanguageAndName(ids.headOption, ids.lastOption)
  }

def getListMenu(pc : (Language, Category)): List[String] = {
    // build the url List("es","category","subcategory1",..."subcategoryN")
  }

found   : net.liftweb.sitemap.**.type
[error]  required: net.liftweb.sitemap.LocPath
[error]     getListMenu(_)) / ** / >> TemplateBox(() => Templates("category" :: Nil)) >> Hidden
[error]                       ^

and show me this error.
Can you help me please?

Nataly Nanda Huanca Patzi

unread,
Jun 19, 2015, 4:50:48 PM6/19/15
to lif...@googlegroups.com

Its working!! but when I made this:


val menuViewFrontEnd = Menu.params[(Language,
Category)]("ViewCategory", "ViewCategory", categoryFrontEnd(_),
    getListMenu(_)) / "category" / ** >> TemplateBox(() => Templates("category" :: Nil)) >> Hidden

How can I do without add "category" ? because when
I made / * / **
show me an error:
Message: net.liftweb.sitemap.SiteMapException: Location ViewCategoryFE defines a duplicate link List(star)
 

Antonio Salazar Cardozo

unread,
Jun 20, 2015, 1:40:21 PM6/20/15
to lif...@googlegroups.com, nataly...@genso.com.bo
Did you try just getListMenu(_)) / ** >> ... ?
Thanks,
Antonio
Reply all
Reply to author
Forward
0 new messages