This project is read-only.

Changing the homepage layout in 1.1?

Topics: Writing themes
May 5, 2011 at 11:11 AM

The site I'm working on at the moment (just a demo site to investigate orchard) requires two subtly different layouts - one for the homepage and one for the rest of the site. The templates are very much alike, the only difference being, the homepage suppresses the main content zone as it's made up of widgets only. Normally I would suppress a zone in the template like this; 

@if (Model.BeforeBody != null)

	<div id="layout-before-body" class="zone">
		<div id="zone-before-body">

But if I try to suppress Model.Content in this way, it's never null and so always outputs empty markup. The way I've been dealing with this, which works perfectly, is using the approach documented here;

However, as the only difference between the two templates is this zone's rendering, I'm wondering if I can suppress this some other way without having to use a filter and two seperate templates?



May 5, 2011 at 7:26 PM

That filter I'm introducing in the post could, instead of adding an alternate, set some custom property on the Layout shape (it's dynamic, you can add anything you want) that you could then test from the template code.

Side note: the custom filter I've been using in my post is not necessary any more if you use the Designer Tools module and its URL alternates feature.

May 6, 2011 at 9:58 AM

Great, did exactly that and works a treat.

Gotta say, loving Orchard...... just wish someone would write a book! :)