This project is read-only.

Return standard contentshapes

Topics: Customizing Orchard
Mar 23, 2014 at 7:24 PM
Hey everyone,

I've build a custom controller to do some filtering and I'm returning a list of ContentItems:

gefilterd = new List<ContentItem>();

The contentItem was created standard via the backend and is called "Wine"

How can I return this to my view with use standard Orchard shapes?

Mar 23, 2014 at 7:53 PM
Edited Mar 23, 2014 at 7:55 PM
Use the IContentManager.BuildDisplay method to build a content shape for each item.
For example:
var displayType = "summary"; // Specifying a display type is optional (and will default to "Detail"). You could also come up with your own display type.

var contentItemShapes = filteredContentItems.Select(x => _contentManager.BuildDisplay(x, displayType));
Mar 23, 2014 at 8:21 PM
well that was easy :)

It even works when putting the list in a viewbag, thanks!
Mar 23, 2014 at 8:41 PM
before I forget, Is there a standard way to display this in a list? So I can benefit from paging etc?
Apr 2, 2014 at 10:21 AM
Anyone? How to return a projection with pagination from custom controller?