Layout based on Page - OrchardCMS
Asked Answered
R

3

8

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.

Recrudescence answered 22/7, 2011 at 14:21 Comment(0)
U
13

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.

Unroof answered 22/7, 2011 at 23:33 Comment(2)
This is basically the route I eventually took - Designer Tools works wonders! I also want to thank you Bertrand, Orchard is fantastic!Recrudescence
I updated the url on this answer - it looks like the gallery has been moved to a subdomain but 301 redirects haven't been implementedCaracaraballo
U
2

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

Ujiji answered 24/7, 2011 at 23:17 Comment(0)
T
1

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.

Timeous answered 22/7, 2011 at 15:27 Comment(1)
Thanks for the suggestion - I was tinkering around with a few things, and I eventually just created a separate Layout for this page. Layout_url_xxxxx.cshtml. Which seems to be working for now.Recrudescence

© 2022 - 2024 — McMap. All rights reserved.