Friday, April 22, 2011

Providing Different Page Layouts for Orchard

Perhaps everyone else and their brother realizes it, but after about 4 hours of searching the web, doing trial and error, I finally figured out how to create different page layouts within Orchard.  Pretty sure this only works with version 1.1+.

Anyway, I’m redoing me website and on my home page, I want my big banner, on the rest of the pages, I just want to jump straight into the content.  This documentation within orchard pointed me in the right direction.

It’s actually pretty easy, simply use the naming convention
     Layout-url-[PAGERELATIVEURL].cshtml

and provide your new template for a completely different page layout.

image

In my cases, I wanted to keep the pages consistent, but I wanted have have my logo and primary image on the home page, and leave it empty on the second page.  The solution was to provide an alternate layout for the BannerZone.cshtml file.

image

BannerZone.cshtml is the default one and will be included on all the pages.  The contents of this file is empty so no image will be displayed.

BannerZone-url-homepage.cshtml will only be displayed when the user is on the home page, the content of this files contains an image tag that will render the main image and logo.

This seems like a very powerful technique to create small tweaks on different pages.  So far, even though it is a very early release. I’m really encouraged what I’m seeing from this platform.  Seems to be very extensible and puts a layer of abstraction for all the blocking-and-tackling stuff you need to build for a custom web site.  I’m hopeful that with these modules and building blocks, we can focus more time on implementing the business needs of our site and less on the ho-hum functionality.

-twb

3 comments:

  1. For every kind of business it needs to be updated by using new software solutions. Some apps could be developed by outsource IT company that provides software development for business companies.

    ReplyDelete
  2. Very interesting tips, looking forward to topic's updates. I want to share in turn with tips how to earn on gambling traffic. The most of casino affiliates look for affiliate program online that meets their requirements.

    ReplyDelete
  3. It's nice article. Let me mention about home insurance by zip that are from house protection companies. Save on free online rates on homeowners insurance.

    ReplyDelete