O'Reilly logo

Orchard CMS: Up and Running by John Zablocki

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Preface

A few months back, I wanted to create an online presence for my band, Daisy’s Gone. In the past, I would have started from scratch. But I remembered all the domains I’ve accumulated over the years that are now nothing more than parking pages at my registrar. It’s generally not hard to throw together a few simple brochure-ware pages. I certainly could have done just that for my band’s site. However, even simple sites often have content and behavior that needs to be dynamic.

The obvious solution is to use a content management system (CMS). CMS platforms such as WordPress and Drupal offer users prebuilt functionality for everything from creating pages to managing site registration. A full-blown CMS will allow non-technical users to create and manage content and will allow programmers and designers to extend the out-of-the-box functionality by creating themes and modules, respectively.

With Daisy’s Gone, I was once again presented with the dilemma of whether to build a site from scratch or to use a CMS. Fortunately, I remembered how I had seen a then just-released Orchard CMS used at the NYC Give Camp a few months earlier. Give Camps match developers and designers with charities who have some unmet technical need, often a web presence. One of the developer groups built its charity a new website using Orchard.

I remember being quite impressed by how much this team accomplished in one weekend using this new CMS. So when it came time to start building the website for my band, I made the choice to use Orchard.

The original Daisy’s Gone website was not much more than a home page. It was primarily a sandbox for me to learn Orchard. As I write this book, I’m going to create a new online presence for the band. I’ll walk through the steps of creating a custom look and feel (themes) and extending Orchard with new functionality (modules).

Whether you are building a new corporate site for your company or a site for the local youth soccer league, you are likely to have many of the same needs of your CMS. Building a site for a band is no different. You may need to schedule events, manage user comments, support OAuth, or have a site map. The content will vary by your domain, the features much less so.

About the Orchard Project

Microsoft released Orchard in January 2011, along with ASP.NET MVC 3, IIS Express, SQL CE 4, Web Farm Framework, and WebMatrix. What all of these technologies have in common is that they, in some way, aim to make web development on Windows more accessible. PHP owes its wide adoption to its perceived ease of use. With this new tool chain, Microsoft is courting the community who wants a simplified development experience.

The Orchard Project belongs to the Microsoft supported Outercurve Foundation (formerly known as the CodePlex Foundation). The Outercurve Foundation is a nonprofit organization whose mission is to foster support for open source projects, such as Orchard and the popular ASP.NET toolkit, MVC Contrib. Microsoft does not officially support Orchard, but its employees are currently among those leading the development efforts for the project.

There are three stated goals of the Orchard Project. The first is to provide a set of shared components to be used in ASP.NET applications. The second is to create a set of reference applications built using these components. The third is to build a community to support these components and applications. At the time of this writing, Orchard is primarily a platform for creating content-driven websites. Though in Orchard, content is certainly not limited to blog posts or simple text-heavy pages.

Orchard is developed with a full open source stack. It uses ASP.NET MVC 3.0 with the Razor view engine. There are also numerous dependencies on other open source projects, most notably NHibernate for data access and Autofac for dependency injection. Orchard is licensed under the BSD license.

Not much more than a year after its 1.0 release, Orchard has been downloaded nearly 1,000,000 times. More than 300 modules and themes have been created and submitted to the Orchard Gallery. A series of minor releases have taken Orchard to its current 1.4 version. The Orchard community is strong and growing.

Why Another .NET CMS?

There have been several commercial and open source .NET CMS products over the years. DotNetNuke (DNN) is arguably the most notable and most popular. However, it was written in VB.NET and remained that way until earlier this year when it was ported to C#. VB.NET was a deal-breaker for me, as it was for many developers.

Even though DNN is a C# project now—as is another popular open source .NET CMS, Umbraco—both are WebForms projects. Like VB.NET, WebForms is also a deal-breaker for me. While the underlying web framework or programming language used by a CMS is of little consequence to an end user, to a programmer it will likely be important. As an MVC developer, I’ve wanted a CMS that is built on ASP.NET MVC and uses metaphors that are familiar to MVC development. I believe the .NET developer community will gravitate towards Orchard, because its development stack is more in line with modern ASP.NET development practices.

That said, it is entirely possible to build content and functionality-rich sites using Orchard without having to write a single line of code. Even though Orchard is a relatively new product, it has a remarkably rich set of extensions. Like other modern CMS products, Orchard marries great programmatic extensibility with rich, out-of-the-box functionality.

Audience

This book is being written for web developers who want to create content-heavy websites without starting from a blank slate. I assume readers have some familiarity with basic CMS concepts and some level of web development skill. Experience with Orchard is neither assumed nor required. Programming custom modules for Orchard does require knowledge of C# and to a lesser extent ASP.NET MVC. If you are unfamiliar with MVC, I suggest reading 20 Recipes for Programming MVC 3 or Programming ASP.NET MVC 4 (O’Reilly) or Programming Microsoft ASP.NET MVC (Microsoft Press).

Many Orchard users will be able to accomplish their goals without having to write any custom code. This book will fully cover how to get a site up and running with Orchard and will walk readers through customization with existing themes and sites from the Orchard Gallery. However, even users who will not be building custom modules might benefit from the chapters describing module and theme architecture. Knowing how Orchard works will help users debug problems that might arise in production.

Contents of This Book

This book introduces Orchard development by walking a reader through the process of creating a customized Orchard site.

Chapter 1 covers getting an Orchard site set up for development and provides a quick tour of the Orchard experience.

Chapter 2 details the process of creating content from existing types of content and covers how to create new types of content.

Chapter 3 describes how to change the way Orchard displays content by default.

Chapter 4 explores the process of customizing an Orchard site’s look and feel by building a theme.

Chapter 5 provides a walkthrough of creating and configuring a custom module.

Chapter 6 provides a walkthrough of creating and configuring a custom widget.

Chapter 7 explores options for adding multi-language support to an Orchard site.

Chapter 8 discusses considerations for maintaining Orchard sites.

Chapter 9 contains the final thoughts on what is covered in this book.

Companion Material

All code samples in this book are available on Bitbucket in my OrchardCMS repository located at https://bitbucket.org/johnzablocki/orchardcms. I use Mercurial for version control. Any general purpose module created in this book will also be available for download in the Orchard Gallery. And of course, you will be able to view the finished project at http://www.daisysgone.com.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.

Tip

This icon signifies a tip, suggestion, or general note.

Caution

This icon indicates a warning or caution.

Using Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Orchard CMS: Up and Running by John Zablocki (O’Reilly). Copyright 2012 John Zablocki, 978-1-449-32021-8.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

Safari® Books Online

Note

Safari Books Online (www.safaribooksonline.com) is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:

http://oreil.ly/orchardcms_upandrunning

To comment or ask technical questions about this book, send email to:

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments

While a team of developers is able to build Orchard full-time, the rest of the Orchard ecosystem comes from the work of the community. I thank these volunteers who leave blog posts and code for Bing to find and the rest of us to follow. Without their efforts, there would not be an Orchard about which to write this book.

I’d like to thank my editor, Rachel Roumeliotis, for giving me the opportunity to write this book. Rachel has been great to work with from the beginning. She understood when a demanding new job slowed my writing pace and when a new release of Orchard invalidated nearly half of my work. I hope to be able to work again with Rachel.

I’d also like to thank O’Reilly Media and its employees who helped get this book published. I realize I am just one piece of many in the puzzle that is turning a bunch of Word documents in a Dropbox folder into a printed work.

Finally, I am forever grateful and thankful to my technical reviewer, Mark Freedman. Mark has long been a colleague and a mentor. He’s helped me not only with this book, but with so many aspects of my career. I consider myself fortunate to have started my career many years ago under Mark’s management. Twelve years later, Mark’s guidance has again proved invaluable. I couldn’t have written this book without him.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required