I'm currently toying around with the Yesod framework, and thought to myself that making a kindda small CMS would be a good project.
At the moment I'm struggling with how one would implement another layout than the defaultLayout. Say, for the admin area of the CMS you would have an adminLayout that would be very different from the defaultLayout.
Is there a way to "replicate" the defaultLayout, and how? - or should I take another approach than this?
Also, I'm fairly new to both Yesod and Haskell, but am chewing my way through it :)
EDIT:
As you may see, I ended up answering my own question. This said, if someone has a better way to go about this, I will be more than happy to accept their question.
After some help from a super nice gentleman[1], a small epiphany occurred. For future googlers looking to do the same thing, I will explain briefly all it took:
I just put this in the handler that I needed it in, all you need is to import the following:
import Yesod.Default.Config (appExtra)
and then define the 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 you'd use defaultLayout. Hope this helps, 'cause I was staring myself blind at the errors a long time -.-' ...
[1] https://groups.google.com/forum/?fromgroups=#!topic/yesodweb/9KpfYBJBwJE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With