How to implement layouts other than defaultLayout

I am currently playing with the Yesod framework and thought that creating a small kindMS CMS would be a good project.

I'm currently struggling with how to implement a different layout than defaultLayout. Say for the CMS administration area you will have adminLayout, which will be very different from defaultLayout.

Is there a way to "replicate" defaultLayout and how? - or should I use a different approach?

Also, I'm pretty new to both Yesod and Haskell, but I'm wading through it :)

EDIT:

As you can see, I answered my question. This suggests that if someone has a better way to do this, I will be more than happy to accept their question.

+7
source share
1 answer

After some help from the super-good gentleman [1], a little insight occurred. For future googlers who want to do the same, I will briefly explain everything you need:

I just put this in the handler I needed, all you need to do is import the following:

import Yesod.Default.Config (appExtra) 

and then define adminLayout as

 adminLayout :: Widget -> Handler Html adminLayout widget = do master <- getYesod mmsg <- getMessage pc <- widgetToPageContent $ do $(combineStylesheets 'StaticR [ css_normalize_css , css_bootstrap_css ]) $(combineScripts 'StaticR [ js_jquery_js , js_bootstrap_min_js ]) $(widgetFile "admin-layout") giveUrlRenderer $(hamletFile "templates/admin-layout-wrapper.hamlet") 

then you can use it, as well as use defaultLayout. Hope this helps, because I have been looking at errors for a long time. -...

[1] https://groups.google.com/forum/?fromgroups=#!topic/yesodweb/9KpfYBJBwJE

+13
source

All Articles