Over the past few weeks I have been playing with the new Projector Module in Orchard CMS. The Projector Module isn't available in the Orchard Gallery yet, but you can download it by enlisting in the Orchard Source Code on CodePlex. Although still in beta, the Projector Module works fine in a lot of the simple scenarios in which I have been testing it. I won't go into the Projector Module in detail since it isn't fully available yet, but I thought I would show you some screenshots just to give you a taste of what it can do. Note that some or all of this may change by the time it is available, but here is an example of using it to display featured and sale products for our e-commerce website based on Orchard CMS.

Orchard E-Commerce Website Product Catalog

So let's pretend for a moment that we have an e-commerce website based on Orchard CMS filled with Products. At a minimum, a Product consists of a Title, Description, List Price, Sale Price, and Tags. For simplicity, we will use the Tags to denote featured and sale products. Featured products have a tag of "Featured" and products on sale have a tag of "OnSale". Yes, this is rudimentary, but it is fine for demonstration purposes. Our client wants us to display a list of featured products and sale products on our homepage by either the lowest list price or sale price accordingly.

We could do this a number of ways, but the Projector Module will really help us here as it will allow us to create queries on products with all kinds of filtering and sorting options. We can then display the results of these queries via a Projection Widget that can be added to any page in the Orchard Website.

Projector Module in Orchard CMS

All this goodness comes in the form of an Orchard Module. Enable the Projector Module which will also enable the Forms and Tokens Modules.

Orchard CMS Projector Module

You may remember a previous Orchard Tutorial, Rules Tokens and Forms in Orchard 1.3, where I discussed the Forms API and Tokens introduced in Orchard 1.3. I won't discuss them in this Orchard Tutorial, but they are important to understand.

Projector Module Queries - Filtering and Sorting

When you have enabled the Projector Module you can now create various queries against the content in your Orchard Website. For our scenario, I built two queries to obtain a list of the featured and sale products by lowest price in our Orchard E-Commerce Website.

Manage Queries with Projector Module in Orchard CMS

Creating these queries using the Projector Module is pretty darn simple. As you can see, you add various filters, specify sorting options, and even specify particular layouts.

Create Queries in Projector Module with Filtering Sorting and Layouts in Orchard CMS

Behind the scenes I did a few things. First, I created a filter, called All Products, that specifies that I only want content items of type Product. I then created another filter, called Tagged as Featured, that specifies I only want those products with a tag of "Featured." As for sorting, I specified that I want the results returned by Price Ascending. I then specified a custom Featured Products Layout in addition to the default layout.

As you would expect, the Sale Products Query is almost identical, expect that I specified products tagged as "OnSale", sorted by sale price, and specified a Sale Products Custom Layout. Creating these queries was very simple and very quick.

Projection Widget in Orchard CMS

We have the queries created and now we need to display the list of featured and sale products on the Orchard E-Commerce Website. One way to do this is via the Projection Widget.

Projection Widget Orchard Website

The special thing about the Projection Widget is that it allows us to specify a query for the results. As you can see in the above Projection Widget used to display sale products on our Orchard Website, I specified the Sale Products Query and the Sales Product Custom Layout. I also created a similar Projection Widget for the featured products in our e-commerce website.

Once the Projection Widgets are added to the website we can display the featured and sale products however we choose. Here is a simple solution using ThemeMachine that displays just the title of the Products and either the list or sale price in ascending order. I only have 2 sale and 2 featured products so they are all displayed in this case.

Orchard E-Commerce Website Display Featured and Sale Products

Return Random Items

The initial feature I saw missing from the Projector Module is the ability to return a random set of items. Many times the client wants to display products, testimonials, specials, list of clients, etc., but wants to display a random set of the items for each page view, etc. This requirement comes up a lot and would be a great addition in functionality.

The Orchard Developer Team recently added Random Sort Criteria to the Projector Module!


The Projector Module in Orchard CMS will prove to be valuable indeed. I look forward to seeing it go into production. If you want to play with it right now, check out the Orchard Source Code on CodePlex. If you are interested in developing Orchard Websites, don't forget to check out my Orchard Tutorials.