how to set different layouts depending on page

Topics: Customizing Orchard
Apr 1, 2012 at 9:15 PM

I am new to Orchard and I am really loving this great CMS. I have created a custom (derived theme) and it works fine but now I am stuck and do not understanding how to do something. I've read much documentation and online but am still a bit confused.

I would like to have 2 different page layouts. One with 2 columns, 3 columns. Each layout will have some significant differences in the CSS file.

What is the best way for me to tell a page which layout it should be using?

I have looked at alternates but am not 100% sure how to use this or if it would be the right approach. I would prefer to not have to put specific naming conventions in my URLs to tell Orchard which layout to display, but if this can't be avoided then I will work with it.

Coordinator
Apr 2, 2012 at 4:03 AM

This should be what you're looking for: http://gallery.orchardproject.net/List/Modules/Orchard.Module.Downplay.Orchard.LayoutSelector

Apr 2, 2012 at 9:04 PM

thank you Bertrand

Apr 8, 2012 at 7:29 AM

Bertrand, I installed the LayoutSelector as detailed in the instructions from the creator's site but I get the following error and I am not sure why because I also downloaded the LayoutSelector project and referenced the binaries in my project. The owner's project website has no contact information so I am unable to follow this up with him :(

 

Line 4:      <legend>Location</legend>
Line 5:      <div>@Html.LabelFor(o => o.LayoutName, @T("Layout"))</div>
Line 6:      <div>@Html.DropDownListFor(o => o.LayoutName, Model.AvailableLayouts.Select(c => new SelectListItem() { Text = c, Value = (c=="Default")?"":c }))</div>
Coordinator
Apr 8, 2012 at 7:54 AM

You didn't copy the error, only where it happens. There is a contact form on the gallery to contact module authors.

Apr 9, 2012 at 2:20 AM
Edited Apr 9, 2012 at 2:21 AM

Hi Betrand, my bad. Here is the other code. The error seems obvious that I must be missing the library as it cannot find a definition for 'AvailableLayouts', however this is odd as I have included a reference to the DLL for the LayoutSelector. Is it possible there is a breaking change with v 1.4?  My full code is below.

 

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1061: 'Downplay.Orchard.LayoutSelector.Models.LayoutSelectorPart' does not contain a definition for 'AvailableLayouts' and no extension method 'AvailableLayouts' accepting a first argument of type 'Downplay.Orchard.LayoutSelector.Models.LayoutSelectorPart' could be found (are you missing a using directive or an assembly reference?)

Source Error:

 

 
Line 4:      <legend>Location</legend>
Line 5:      <div>@Html.LabelFor(o => o.LayoutName, @T("Layout"))</div>
Line 6:      <div>@Html.DropDownListFor(o => o.LayoutName, Model.AvailableLayouts.Select(c => new SelectListItem() { Text = c, Value = (c=="Default")?"":c }))</div>
Line 7:      
Line 8:      <!--<select>


Source File: c:\Inetpub\wwwroot\MyProject\Modules\Downplay.Orchard.LayoutSelector\Views\EditorTemplates\Parts\LayoutSelector.cshtml    Line: 6 

Coordinator
Apr 9, 2012 at 5:03 AM

Your best bet is to contact the author through the gallery, but my guess would be that the module actually did not compile for some reason. Check your logs (app_data\logs).

Apr 12, 2012 at 4:26 AM

I am still not having luck with this. I tried contacting the two main developers for the Layout Selector and still have no luck.

I really need this to work but don't want to give up on Orchard because this component wont work. Please, has anybody experienced this issue and is able to help?

Coordinator
Apr 12, 2012 at 4:38 AM

Maybe you should try to fix it yourself, if they are not responding.

Apr 12, 2012 at 5:24 AM
bertrandleroy wrote:

Maybe you should try to fix it yourself, if they are not responding.

of course that was my first option but not any luck. the module compiles fine on its own, but the latest orchard 1.4 out of the box wont compile, so i can't try and build the two together.