How to set header/footer in every pages (View) in a custom module? Layout = "~/Views/Shared/_Layout.cshtml"; Doesn't work!

Topics: Writing modules
Mar 5, 2013 at 6:13 PM
In a custom module Views, I need to add header/footer in each page (within my custom module)

So I add the following MVC code into each View, but it doesn't work with Orchard!

@{
Layout = "~/Views/Shared/_Layout.cshtml";
}

It says:

Orchard.Mvc.ViewEngines.Razor.WebViewPage<> cannot be assigned to -- it is read only____
Developer
Mar 7, 2013 at 1:12 AM
In Orchard the Layout property means something different: it's a Shape.
Question: why are you doing this from your module instead of your theme?
Mar 9, 2013 at 9:09 PM
In Orchard the Layout property means something different: it's a Shape.
Question: why are you doing this from your module instead of your theme?
Thanks sfmskywalker, all I try to is, add standard HEADER and FOOTER on each pages(view) inside of my module.
So if I can't use the MVC way: _Layout = "~/Views/Shared/_Layout.cshtml"; _
what else I can do it Orchard?
Developer
Mar 13, 2013 at 2:16 AM
If you insist, you could do it from your module by adding a Header and Footer shape to a zones on the Layout (an action filter would be a good candidate to do it from). But even then, in your theme, you would have to render the two zones that renders the shapes if you're using zones that have not been defined yet. There's of course the Tail zone defined in Document.cshtml, and you could introduce a new zone by overriding Document.cshtml in your theme and add the header shape there.