I am looking for a way to hide certain zones on 1 particular page in Orchard CMS, I am using version 1.6.1.
Some background to my issue - every page on the site has a header and footer as defined in the Layout.cshtml
file. For 1 page on the site I want to hide the header and footer which is made up of 6 zones. In MVC I would add another layout file and use nested layouts but I know this can't be done in Orchard.
I have a solution that does the job, however I am not keen on it as it involves putting code in the Layout.cshtml
file, my solution is as follows
if (Request.Url.PathAndQuery.Contains("register-1"))
{
Model.Header1 = null;
Model.Header2 = null;
Model.Header3 = null;
Model.Header4 = null;
Model.Footer1 = null;
Model.Footer2 = null;
}
This is coupled with doing a null check before outputting the zone like so
@if (Model.Header1 != null)
{
<div id="layout-banner">
@Zone(Model.Header1)
</div>
}
Is there a way to do this without having to put code in the Layout.cshtml
file? Or perhaps there is a better approach all together?
Use a layer to hide the widgets, that uses a not url("~/register-1")
to exclude the page. The widgets that are placed in this layer will not appear on your register-1 page.