Yeah, Full(()) makes sense for 1.1-SNAPSHOT which is what my code was using,
and Full(NullLocParams) makes sense for M7 and earlier. I apologize; I should
have asked what version you were developing against.
I think that you are correct with regard to the top level menu having to be
static -- looking at it it seems like only child menu items can be dynamic.
Maybe you can have one top level Menu and then use a custom Menu snippet that
skips the top level? Someone with more experience doing deep SiteMap stuff
hopefully can chime in.
-Ross
On Nov 21, 2009, at 8:51 AM, philip wrote:
> Got my code working so it generates a menu.
>
> Looked at WikiLoc in the Wiki Liftweb example, it has:
> def defaultParams = Full(WikiLoc("HomePage", false))
> So I guessed that it needs to have something with a Full
>
> Changed it to:
> override val defaultParams = Full(NullLocParams)
>
> So now my code is
>
> case class DynMenuLoc (
> override val name: String,
> override val link: Link[NullLocParams],
> override val text: LinkText[NullLocParams],
> _params: LocParam* ) extends Loc[NullLocParams] {
> override val params = _params.toList
> // had to comment this out: override val defaultValue = Full(())
> // not sure what to set this to
> override val defaultParams = Full(NullLocParams)
>
> override def supplimentalKidMenuItems:List
> [net.liftweb.sitemap.MenuItem] = {
> Log.info("kid menu function called")
> var result:ListBuffer[net.liftweb.sitemap.MenuItem] = new
> ListBuffer[net.liftweb.sitemap.MenuItem]
> result + (new MenuItem(Text("AAAAA"), Text("BBBBB"), Nil, false,
> false, Nil))
> result + (new MenuItem(Text("CCCCC"), Text("DDDDD"), Nil, false,
> false, Nil))
> result.toList ::: super.supplimentalKidMenuItems
> }
> }
>
> Thats great, but still there is a problem of the top level menu.
>
> On 11月21日, 下午2時56分, Ross Mellgren <[email protected]> wrote:
>> Here's an example of doing what David decribed (at least, as I understood it
>> ;-) ):
>>
>> // In Boot.scala
>> // Build SiteMap
>> val entries = ... ::
>> Menu(DynMenuLoc("Dynamic Menu", Link(List("dynamic"), true,
>> "/dynamic"), "Dynamic Menu")) ::
>> ...
>>
>> case class DynMenuLoc (
>> override val name: String,
>> override val link: Link[Unit],
>> override val text: LinkText[Unit],
>> _params: LocParam[Unit]*
>> ) extends Loc[Unit] {
>> override val params = _params.toList
>> override val defaultValue = Full(())
>>
>> override def supplimentalKidMenuItems = {
>> DynMenuItem.findAll.map(dmi => {
>> MenuItem(Text(dmi.label.is), Text(dmi.link.is), Nil, false,
>> false, Nil)
>> }) ::: super.supplimentalKidMenuItems
>> }
>>
>> }
>>
>> object DynMenuItem extends DynMenuItem with LongKeyedMetaMapper[DynMenuItem]
>> with CRUDify[Long, DynMenuItem]
>>
>> class DynMenuItem extends LongKeyedMapper[DynMenuItem] with IdPK {
>> def getSingleton = DynMenuItem
>>
>> object label extends MappedString(this, 32)
>> object link extends MappedString(this, 255)
>>
>> }
>>
>> I can post the full example code on github if it'd help, also.
>>
>> -Ross
>>
>> On Nov 20, 2009, at 10:37 PM, philip wrote:
>>
>>
>>
>>> Hi David,
>>
>>> Really looking forward to this - I spent a day on this with absolute
>>> failure.
>>
>>> Philip
>>
>>> On 11月20日, 上午1時56分, David Pollak <[email protected]>
>>> wrote:
>>>> Philip & list,
>>
>>>> I've had it on my to-do list to write up an example... and haven't...
>>>> but...
>>
>>>> In your Loc, you can override def supplimentalKidMenuItems and dynamically
>>>> generate kid menu items.
>>
>>>> I'll try to get to an example.... but not today... sorry :-(
>>
>>>> Thanks,
>>
>>>> David
>>
>>>> On Thu, Nov 19, 2009 at 12:35 AM, philip <[email protected]> wrote:
>>
>>>>> Hi David,
>>
>>>>> Since I am programming a CMS for my client, I need my lift menu to
>>>>> come from the database.
>>
>>>>> LiftRules.setSiteMap(SiteMap(MenuInfo.menu :_*))
>>
>>>>> def menu: List[Menu] =
>>>>> {
>>>>> Log.info("Menu called")
>>>>> ...
>>
>>>>> It seems my menu function only gets called once, on subsquent calls I
>>>>> do not get any log message.
>>
>>>>> Maybe I have to subclass SiteMap?
>>
>>>>> Can you point me in the right direction?
>>
>>>>> Thanks, Philip
>>
>>>>> On 10月21日, 下午11時20分, David Pollak <[email protected]>
>>>>> wrote:
>>>>>> I owe the list example code to do this... maybe tomorrow.
>>
>>>>>> On Wed, Oct 21, 2009 at 6:26 AM, philip <[email protected]> wrote:
>>
>>>>>>> Hi,
>>
>>>>>>> How can I get a Liftweb menu to be generated from database content?
>>
>>>>>>> Alternatively, can the menu come from a XML datasource? could I load/
>>>>>>> serialize from that?
>>>>>>> Could it change dynamically at any time?
>>
>>>>>>> Thanks, Philip
>>
>>>>>> --
>>>>>> Lift, the simply functional web frameworkhttp://liftweb.net
>>>>>> Beginning Scalahttp://www.apress.com/book/view/1430219890
>>>>>> Follow me:http://twitter.com/dpp
>>>>>> Surf the harmonics
>>
>>>>> --
>>
>>>>> You received this message because you are subscribed to the Google Groups
>>>>> "Lift" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected]<liftweb%[email protected]>
>>>>> .
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/liftweb?hl=.
>>
>>>> --
>>>> Lift, the simply functional web frameworkhttp://liftweb.net
>>>> Beginning Scalahttp://www.apress.com/book/view/1430219890
>>>> Follow me:http://twitter.com/dpp
>>>> Surf the harmonics- 隱藏被引用文字 -
>>
>>>> - 顯示被引用文字 -
>>
>>> --
>>
>>> You received this message because you are subscribed to the Google Groups
>>> "Lift" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group
>>> athttp://groups.google.com/group/liftweb?hl=.- 隱藏被引用文字 -
>>
>> - 顯示被引用文字 -
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=.
>
>
--
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=.