Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 239
Rion Williams Avatar asked Jul 22 '11 14:07

Rion Williams


3 Answers

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.

like image 184
Bertrand Le Roy Avatar answered Nov 14 '22 01:11

Bertrand Le Roy


You can use the Layout Selector Module to assign a custom layout to any content item.

http://gallery.orchardproject.net/List/Modules/Orchard.Module.Orchard.DesignerTools

like image 29
DanielEli Avatar answered Nov 14 '22 00:11

DanielEli


You could use the Vandelay.Classy module to add custom tags to the page that represents your homepage, although it does add a lot of fields to the Page content editor.

like image 1
mdm Avatar answered Nov 14 '22 01:11

mdm