Is there a possibility to have a sitewide variables in Yesod? Suppose, I have main menu which entries are gathered from DB and that is rendered on every page: should i fetch entries manually in each handler?
I've tried to do this in Foundation.hs in instance Yesod App
declaration in defaultLayout
:
instance Yesod App where
...
defaultLayout widget = do
...
entries <- runDB $ selectList [RubricOnTop ==. True] []
...
But this fails to compile: i have a type mismatch Entity
with RubricGeneric
.
Solution
$forall rubric <- map entityVal rubrics
...
in default-layout-wrapper.hamlet. Haven't found solution to do this in defaultLayout function yet.