How do I implement layouts other than defaultLayout?

Showing 1-6 of 7 messages
How do I implement layouts other than defaultLayout? Si 11/2/12 7:35 AM
I just tried to duplicate defaultLayout as "adminLayout" in a Handler module, but found the following issues:

Not in scope: data constructor `LogoutR'
    In the result of the splice:
      $(hamletFile "templates/default-layout-wrapper.hamlet")

Not in scope: `appExtra'
    In the result of the splice:
      $(hamletFile "templates/default-layout-wrapper.hamlet")

The code duplicated from defaultLayout, and the templates referenced, have only minor code changes from the standard scaffolding versions. The LogoutR refers to the Auth subsite logout route, and the appExtra is due to the scaffold inclusion of a copyright setting.

Other "top level" routes are generated correctly, and "pages" work generally through the new layout, so I guess I need to do something more to get back the extra context needed for finding those functions in scope (as if it were declared like the Yesod App instance).

What's the recommended way to create layouts other than the defaultLayout? Am I on the wrong track, or just missing something?

Thanks,
Si
Re: [Yesod] How do I implement layouts other than defaultLayout? Michael Snoyman 11/3/12 8:46 AM

I think the issue is just one of missing imports. LogoutR comes from Yesod.Auth and appExtra from Foundation.hs (I think).

Re: [Yesod] How do I implement layouts other than defaultLayout? Si 11/3/12 9:41 AM
You're quite right! Fixed with:

import Yesod.Auth (Route(LogoutR))
import Yesod.Default.Config (appExtra)

This will enable me to start work on the other roles in my system. Thanks :)
Re: [Yesod] How do I implement layouts other than defaultLayout? Si 11/12/12 9:25 AM
Hiya,

It might be easiest to start with your adminLayout function in a handler, then move it out to a separate module, adding the other imports needed.

I use a Layout module that I include in Import.hs for convenience, but that requires you to work around cyclic dependencies when it's more fruitful to get your layout function working first.

If you clone the defaultLayout, and have scaffold templating, you'll certainly need:

import Yesod.Default.Config (appExtra)

I think the rest will be provided by the standard Import.hs import.

What error are you seeing?

Si

On Monday, November 12, 2012 6:05:54 PM UTC+1, Christian Laustsen wrote:
Hi, 
terribly sorry to rip open this thread, but I'm struggling with a doing an adminLayout also and was wondering how you went about it?
Re: [Yesod] How do I implement layouts other than defaultLayout? Christian Laustsen 11/12/12 9:34 AM
Wow, seemed like import Yesod.Default.Config (appExtra) was all i was missing :)

was staring myself blind at this, thanks so much for taking time to answer!

sincerely Christian
Re: [Yesod] How do I implement layouts other than defaultLayout? Si 11/12/12 9:38 AM
Ha! Very much like the issue I had at the time then.

I convinced myself somehow that "magic" was happening, perhaps related to it being a class instance function, and overlooked the obvious.