You are on page 1of 8

4/10/2015 Tales 

from the Evil Empire ­ A quick look at what’s new in Orchard 0.8

A quick look at what’s new in Orchard 0.8
Thursday, October 28, 2010
ASP.NET (/bleroy/Tags/ASP.NET)   Clay (/bleroy/Tags/Clay)   CMS (/bleroy/Tags/CMS)   MVC (/bleroy/Tags/MVC)
Orchard (/bleroy/Tags/Orchard)

We shipped Orchard 0.8 on Monday
(http://orchard.codeplex.com/releases/view/49388) and it’s the
last release we will make before 1.0, which is scheduled for
January 2011. We think it’s a pretty nice release in that it wraps
up the UI story for the platform.

1. New theme engine with Razor and Clay
ASP.NET MVC, on which Orchard is built, supports alternative
view engines. Orchard does too, and 0.8 is the first release
where the new Razor view engine is the default. All existing views in Orchard have been moved to
Razor. An introduction to Razor syntax can be found here:

http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing­razor.aspx
(http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing­razor.aspx)

We also improved the way view models are built in Orchard: in a CMS, the type system needs to be
flexible enough to allow for the dynamic creation of new composite types at runtime. That very flexible
data model then needs to be morphed into markup, which makes using statically­typed view models
hard. Instead, Orchard builds for each page an intermediary Page Object Model (POM) that will
represent the data structure of the page with dynamic objects. Those dynamic objects, which we call
shapes, are extremely easy to build, modify and extend at runtime: they are Clay objects
(http://weblogs.asp.net/bleroy/archive/tags/Clay/default.aspx).

Shapes are the representation of arbitrary semantic constructs that are then going to be rendered by the
theme engine. Examples of shapes are layouts, zones, menus, menu items, pagers or whatever you
want to add. Here is an example of shape creation:

var msg = New.Message(
  Content: T("This is a test"),
  Severity: "Really bad!!!");

No Message type is pre­existent here, we are creating a Message shape with two properties on the fly.
After this, you can for example access the Content property as expected: msg.Content.

If that shape has been added to another shape in the POM, when it comes time to render it, the theme
engine will look for a message.cshtml template in the views folder of the current theme and will hand it
the shape as the model and render it.

https://weblogs.asp.net/bleroy/a­quick­look­at­what­s­new­in­orchard­0­8 1/8
4/10/2015 Tales from the Evil Empire ­ A quick look at what’s new in Orchard 0.8

<div>
  @T("Something happened: {0}. It's that bad: {1}.",
     model.Content,
     model.Severity)
</div>

Alternatively, instead of using a template, you can use a shape method. This is useful when you want to
define the default rendering of small shapes. Shape methods are methods marked with the Shape
attribute and have the name of the shape to render.

For example, the above message could be also rendered using the following method:

[Shape]
public IHtmlString Message(string Content, string Severity) {
    return T("Something happened: {0}. It's that bad: {1}.",
        Content, Severity);
}

Themes can also contain dynamically compiled code and in principle could do everything a module can
do. That enables a theme to have its own control panel for example.

2. Widgets!
The second big feature of this release is widgets. Widgets are small pieces of reusable UI that can be
arbitrarily positioned on the pages of your site. Examples of widgets could include a tag cloud such as
the one you can see in the left sidebar of this blog, or a search form, a twitter feed or whatever you can
dream of.

In Orchard, widgets are content types, which enabled us to reuse a lot of existing APIs and UI, and which
will enable you to factor a lot of your work efficiently between regular content types and widgets.

For example, if you look at the optional map module
(http://orchardproject.net/gallery08/Media/Resource/Maps­.zip?ContentType=application%2Fx­package)
that is available on the Orchard module gallery (http://www.orchardproject.net/gallery), you will see that
the map really is implemented as a content part. A content part is a small piece of content focused on a
specific task such as mapping.

You can add the map part to your own content types. For example, you could add a map to an event
content type and show the location of that event.

Because a widget is a content type, and the map is a content part, building a map widget is trivial. Here’s
how you do it:

ContentDefinitionManager.AlterTypeDefinition(
  "MapWidget", cfg => cfg
    .WithPart("MapPart")
    .WithPart("WidgetPart")
    .WithPart("CommonPart")
    .WithSetting("Stereotype", "Widget"));

https://weblogs.asp.net/bleroy/a­quick­look­at­what­s­new­in­orchard­0­8 2/8
4/10/2015 Tales from the Evil Empire ­ A quick look at what’s new in Orchard 0.8

This code is creating a new content type named MapWidget with the common part, the map part, and
the widget part and stereotype (that makes it a real widget and not just a plain content type).

You can then go to the manage widgets admin panel and see the map widget in the list of available
widgets:

You can also see on the left the list of layers, and in the middle the list of available zones.

Layers consist of a rule that determines what pages the widgets of the layer apply to, a set of widgets,
their zone assignments, display orders and configuration.

Before you add a widget, you need to decide where it’s going to appear. Do I want it on the homepage
only, on all pages, only for authenticated users, or somewhere else based on some other criterion?

If there already is an existing layer with the rule you want, use it, otherwise you’ll have to create your
own. For example, let’s create a rule that will apply only for the About page:

https://weblogs.asp.net/bleroy/a­quick­look­at­what­s­new­in­orchard­0­8 3/8
4/10/2015 Tales from the Evil Empire ­ A quick look at what’s new in Orchard 0.8

I’ve entered a very simple rule which is that the rul is ~/about. You can in fact write much ore complex
rules as the language that’s being used to parse the rules here is IronRuby (http://ironruby.net/). That
means you can use nots, ors and ands in there and combine rules in any creative way you want. You
can even add your own rule syntax if you want to by implementing IRuleProvider. Orchard comes with
the url and authenticated rule providers which you can see in use in the TheHomePage, Authenticated
and Anonymous layers.

https://weblogs.asp.net/bleroy/a­quick­look­at­what­s­new­in­orchard­0­8 4/8
4/10/2015 Tales from the Evil Empire ­ A quick look at what’s new in Orchard 0.8

The list of zones you can see in the widget management page comes
from the theme’s manifest:

Name: The Theme Machine
Author: jowall, mibach,
  loudej, heskew
Description: Orchard Theme
  Machine is a flexible
  multi‐zone theme that
  provides a solid
  foundation to build
  your site.
  It features collapsible
  widget zones and is
  flexible enough to cover
  a wide range of layouts.
Version: 0.1
Tags: Awesome
Zones: Header, Navigation,
  Featured, BeforeMain,
  AsideFirst, Messages,
  BeforeContent, Content,
  AfterContent, AsideSecond,
  AfterMain, TripelFirst,
  TripelSecond, TripelThird,
  FooterQuadFirst, FooterQuadSecond,
  FooterQuadThird, FooterQuadFourth,
  Footer

All the zones available across all the layouts of the current theme will be displayed on the widget
management screen. The one I’m interested in here is AsideSecond. After I clicked “Add to Zone” next to
the map widget, I could configure it with the AsideSecond zone, and then give it a title and the location of
the core team:

https://weblogs.asp.net/bleroy/a­quick­look­at­what­s­new­in­orchard­0­8 5/8
4/10/2015 Tales from the Evil Empire ­ A quick look at what’s new in Orchard 0.8

After saving and navigating to the about page, I can see my map in place:

3. The rest
https://weblogs.asp.net/bleroy/a­quick­look­at­what­s­new­in­orchard­0­8 6/8
4/10/2015 Tales from the Evil Empire ­ A quick look at what’s new in Orchard 0.8

Orchard 0.8 shipped with a number of smaller features such as e­mail notifications, more pagination
support and various little improvements. Of course, it’s not perfect, and we had our share of regressions
(see release notes (http://orchard.codeplex.com/releases/view/49388#DownloadId=160290)), but we’re
advancing.

We are now sprinting to 1.0 which will be released in January. There is a lot left to do, in particular for
performance, security and hosting (medium trust has been a much requested feature since we started
the project for example).

But even 1.0 will be only the beginning: it will be a platform much more than a finished CMS. There are
lots of small and big features that we deprioritized in favor of infrastructure in order to ship in January.

See this as an opportunity: the community (that’s you) will provide lots of these missing features and
much more. If you are a student, there is even a competition going on as part of the Imagine Cup
(http://imaginecup.com/competitions/orchard) that could win you a nice trip to NYC.

So go, go, go! Make themes! Make widgets! Make modules! Make amazing stuff!

Orchard 0.8: 
http://orchard.codeplex.com/releases/view/49388 (http://orchard.codeplex.com/releases/view/49388)

6 Comments
Actually, I'm learning to extend Orchard and sure it will be a great CMS platform. 
Thank you very much for doing a good thing for us. 
—  embarus (http://codesanook.com) ­ Friday, October 29, 2010 1:38:11 AM (/bleroy/a­quick­look­at­what­s­new­in­orchard­
0­8#comment­896)

Looks facinating and clean. I'm curous about a contrast with DotNetNuke, which is the de facto
heavy player in the open­source .NET environment currently. 

The DNN community has done some MVC exploration, but I understand you are completely there. 

Also they have a sitemap structure (with pages having a skin and set of modules on the page),
where your layers seem to be more flexible and Drupal­like. 

What are the other differences in architecture?! 
—  John C ­ Friday, October 29, 2010 7:59:57 PM (/bleroy/a­quick­look­at­what­s­new­in­orchard­0­8#comment­897)

Sooo, how are companies like Kentico or Telerik reacting to this? Because to me it seems that by
looking at Orchard as a platform, it will eat those silly limited CMS vendors for lunch... 
—  Mike ­ Friday, October 29, 2010 8:00:17 PM (/bleroy/a­quick­look­at­what­s­new­in­orchard­0­8#comment­898)

https://weblogs.asp.net/bleroy/a­quick­look­at­what­s­new­in­orchard­0­8 7/8
4/10/2015 Tales from the Evil Empire ­ A quick look at what’s new in Orchard 0.8

Orchard will be a very great platform... thanks for building such a great piece of software... 
—  wooncherk (http://panorazzi.com) ­ Sunday, October 31, 2010 2:34:45 AM (/bleroy/a­quick­look­at­what­s­new­in­
orchard­0­8#comment­899)

Sure does look like an absolutely awesome start. Thank you for laying the foundation on this guy,
going to start playing with it tonight. 
—  Don W. ­ Wednesday, November 3, 2010 10:19:03 PM (/bleroy/a­quick­look­at­what­s­new­in­orchard­0­8#comment­900)

@Gregg: we are talking about it, evaluating options. It's way too early to jump to conclusions
though. 
—  Bertrand Le Roy (http://weblogs.asp.net/bleroy/) ­ Thursday, November 4, 2010 4:20:00 AM (/bleroy/a­quick­look­at­
what­s­new­in­orchard­0­8#comment­901)

Comments have been disabled for this content.

Terms Of Use (http://www.asp.net/terms­of­use) ­ Powered by Orchard (http://www.orchardproject.net)

https://weblogs.asp.net/bleroy/a­quick­look­at­what­s­new­in­orchard­0­8 8/8

You might also like