Tales from the Evil Empire

Bertrand Le Roy's blog


Bertrand Le Roy

BoudinFatal's Gamercard

Tales from the Evil Empire - Blogged

Blogs I read

My other stuff


July 2012 - Posts

A quick guide to the built-in Orchard modules

With the imminent release of Orchard 1.5, the number of built-in modules in the default distribution is getting quite impressive, if not intimidating. Now may be a good time to give new and old users a tour of what comes out of the box. Who knows, we may discover a hidden nugget or two along the way…

I just finished writing a massive documentation topic that describes all Orchard features that come with the source code and WebPI distributions:

All built-in Orchard modules described

I added the guide to the official Orchard documentation site. It details what modules come in the default package, which are only available from the source code package or from the gallery, and also mentions which are enabled by default.

Documentation, like everything in Orchard, is open source, so you can contribute to this topic and others: Edit this topic.

I hope this helps.

My Body Summary template for Orchard

(c) Bertrand Le Roy 2012By default, when Orchard displays a content item such as a blog post in a list, it uses a very basic summary template that removes all markup and then extracts the first 200 characters. Removing the markup has the unfortunate effect of removing all styles and images, in particular the image I like to add to the beginning of my posts.

Fortunately, overriding templates in Orchard is a piece of cake. Here is the Common.Body.Summary.cshtml file that I drop into the Views/Parts folder of pretty much all Orchard themes I build:

    Orchard.ContentManagement.ContentItem contentItem =
    var bodyHtml = Model.Html.ToString();
    var more = bodyHtml.IndexOf("<!--more-->");
    if (more != -1) {
        bodyHtml = bodyHtml.Substring(0, more);
    else {
        var firstP = bodyHtml.IndexOf("<p>");
        var firstSlashP = bodyHtml.IndexOf("</p>");
        if (firstP >=0 && firstSlashP > firstP) {
            bodyHtml = bodyHtml.Substring(firstP, firstSlashP + 4 - firstP);
    var body = new HtmlString(bodyHtml); 
<p>@Html.ItemDisplayLink(T("Read more...").ToString(), contentItem)</p>

This template does not remove any tags, but instead looks for an HTML comment delimiting the end of the post’s intro:


This is the same convention that is being used in WordPress, and it’s easy to add from the source view in TinyMCE or Live Writer.

If such a comment is not found, the template will extract the first paragraph (delimited by <p> and </p> tags) as the summary.

And if it finds neither, it will use the whole post.

The template also adds a localizable link to the full post.

More Posts