Search code examples
layoutorchardcmsstyling

Layout based on Page - OrchardCMS


I have encountered an issue when using Orchard that I am sure there should be a fairly simple fix / solution for, but I have yet to find it.

I am trying to establish a specific width content area for my home page (580px), and a larger width for content pages (800px).

Layout.cshtml Snippet:

    <div id='content'>
        @Zone(Model.Content)
    </div>

Style:

    #Content
    {
        [...]
        width: 580px;
    }

Currently - the Content div wraps all of my content regardless of the page (either Home Page or Content). I am wondering if it is possible to use a different div to wrap the content based on the Page, as shown:

Layout.cshtml Idea:

@if(Model.Page != "Home")
{
    <div id='fullcontent'>
        @Zone(Model.Content)
    </div>
}
else
{
    <div id='content'>
        @Zone(Model.Content)
    </div>
}

I'm unsure if the above suggested method is possible (or I am unsure how to check for the current Page) - but any other suggestions would be appreciated.


Solution

  • You can use the Designer Tools module (built-in all recent Orchard versions) and enable the URL alternates feature. You'll then be able to create a layout-url-homepage.cshtml alternate for your layout.